+

Search Tips   |   Advanced Search

Configure processes using scripting

Use the wsadmin tool to configure processes in the application server configuration. Enhance the operation of an application server by defining command-line information for starting or initializing the application server process. Process definition settings define runtime properties such as the program to run, arguments to run the program, and the working directory.

There are three ways to perform this task. Complete the steps in this task to use the setProcessDefinition command for the AdminTask object or the AdminConfig object to modify the process definition configuration. Alternatively, we can use the configureProcessDefinition Jython script in the AdminServerManagement script library to configure process definition attributes. The wsadmin tool automatically loads the script when the tool starts. Use the following syntax to configure process definition settings using the configureProcessDefinition script:

AdminServerManagement.configureProcessDefintion(nodeName, serverName, otherParamList)
For additional information and argument definitions, see the documentation for the AdminServerMananagment script library.


Tasks

  1. Start the wsadmin scripting tool.

  2. Use the setProcessDefinition command for the AdminTask object or the AdminConfig object to modify the process definition configuration.

    • Use the following example to configure the process definition with the setProcessDefinition command for the AdminTask object:

    • Use the following steps to configure the process definition with the AdminConfig option:

      1. Identify the server and assign it to the s1 variable, as the following example demonstrates:

        • Use Jacl:
          set s1 [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]
          

        • Use Jython:
          s1 = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/')
          print s1
          

        Element Description
        set Jacl command
        s1 Variable name
        $ Jacl operator for substituting a variable name with its value
        AdminConfig Object that represents the WebSphere Application Server configuration
        getid AdminConfig command
        Cell Object type
        mycell Name of the object that will be modified
        Node Object type
        mynode Name of the object that will be modified
        Server Object type
        server1 Name of the object that will be modified
        print Jython command

        Example output:

        server1(cells/mycell/nodes/mynode/servers/server1|server.xml#Server_1)
        
      2. Identify the process definition for the server of interest, and assign it to the processDef variable:

        • Use Jacl:
          set processDef [$AdminConfig list JavaProcessDef $s1]
          set processDef [$AdminConfig showAttribute $s1 processDefinitions]
          
          (ZOS)
          set processDefs [$AdminConfig list JavaProcessDef $s1]
          set controllerProcessDef [lindex $processDefs 1]
          set servantProcessDef [lindex $processDefs 1]
          

        • Use Jython:
          processDef = AdminConfig.list('JavaProcessDef', s1)
          print processDef
          processDef = AdminConfig.showAttribute(s1, 'processDefinitions')
          
          (ZOS)
          processDefs = AdminConfig.list('JavaProcessDef', s1)
          # get line separator
          import java
          lineSeparator = java.lang.System.getProperty('line.separator')
          arrayPDs = processDefs.split(lineSeparator)
          controllerProcessDef = arrayPDs[0]
          servantProcessDef = arrayPDs[1]
          print controllerProcessDef
          print servantProcessDef
          

        Example output:

        (cells/mycell/nodes/mynode/servers/server1|server.xml#JavaProcessDef_1)
        
        (ZOS)
        (cells/mycell/nodes/mynode/servers/server1:server.xml#JavaProcessDef_1)
        (cells/mycell/nodes/mynode/servers/server1:server.xml#JavaProcessDef_2)
        

      3. Modify the configuration attributes for the process definition.

        The following example changes the working directory:(ZOS) On z/OS systems, the following example shows how to change the process definition of the servant region. We can change the process definition of the controller region by substituting controllerProcessDef for servantProcessDef .

        • Use Jacl:(Dist)
          $AdminConfig modify $processDef {{workingDirectory c:/temp/user1}}
          
          (ZOS)
          $AdminConfig modify $servantProcessDef {{workingDirectory /temp/user1}}
          
          (iSeries)
          $AdminConfig modify $processDef {{workingDirectory /home/myProfile/temp/user1}}
          

        • Use Jython:(Dist)
          AdminConfig.modify(processDef, [['workingDirectory', 'c:/temp/user1']])
          
          (ZOS)
          AdminConfig.modify(servantProcessDef, [['workingDirectory', '/temp/user1']])
          
          (iSeries)
          AdminConfig.modify(processDef, [['workingDirectory', '/home/myProfile/temp/user1']])
          

        The following example modifies the name of the stderr file:

        • Use Jacl:
          set errFile [list stderrFilename \${LOG_ROOT}/server1/new_stderr.log]
          set attr [list $errFile]
          $AdminConfig modify $processDef [subst {{ioRedirect {$attr}}}]
          
          (ZOS)
          set errFile [list stderrFilename \${LOG_ROOT}/server1/new_stderr.log]
          set attr [list $errFile]
          $AdminConfig modify $servantProcessDef [subst {{ioRedirect {$attr}}}]
          

        • Use Jython:
          errFile = ['stderrFilename', '\${LOG_ROOT}/server1/new_stderr.log']
          attr = [errFile]
          AdminConfig.modify(processDef, [['ioRedirect', [attr]]])
          
          (ZOS)
          errFile = ['stderrFilename', '${LOG_ROOT}/server1/new_stderr.log']
          attr = [errFile]
          AdminConfig.modify(servantProcessDef, [['ioRedirect', attr]])
          

        The following example modifies the process priority level:

        • Use Jacl:
          $AdminConfig modify $processDef {{execution {{processPriority 15}}}}
          

        • Use Jython:
          AdminConfig.modify(processDef, [['execution', [['processPriority', 15]]]])
          

        The following example changes the maximum number of times the product tries to start an application server in response to a start request. If the server cannot be started within the specified number of attempts, an error message is issued that indicates that the application server could not be started.

        • Use Jacl:
          $AdminConfig modify $processDef {{monitoringPolicy {{maximumStartupAttempts 1}}}}
          

        • Use Jython:
          AdminConfig.modify(processDef, [['monitoringPolicy', [['maximumStartupAttempts',  1]]]])
          

  3. Save the configuration changes.
    AdminConfig.save()
    
  4. In a network deployment environment only, synchronize the node.

    Use the syncActiveNode or syncNode scripts in the AdminNodeManagement script library to propagate the configuration changes to node or nodes.

    • Use the syncActiveNodes script to propagate the changes to each node in the cell:
      AdminNodeManagement.syncActiveNodes()
      

    • Use the syncNode script to propagate the changes to a specific node:
      AdminNodeManagement.syncNode("myNode")
      

  • Define application server processes
  • wsadmin AdminConfig
  • Process definition settings
  • Server settings configuration scripts
  • Node administration scripts
  • Commands for the AdminConfig object