Configuring an independent integration server startup script

You can configure an independent integration server to run a script when it starts up, by setting properties in the independent integration server's server.conf.yaml configuration file. By using this capability, you can run commands to reconfigure the independent integration server at startup. This capability is not available for an integration server that is associated with an integration node.

Before you begin

About this task

You can configure an independent integration server to run a script when it is started, by modifying the StartupScripts section of the server.conf.yaml file, in which you specify the script to be run. For example:


StartupScripts:
  FirstScript:
    command: '/tmp/myscript.sh'
    #readVariablesFromOutput: 'auto'    # Controls whether the server reads environment and user variables from the script output. 
                                        # Possible values are 'true', 'false', and 'auto' (default).
    directErrorToCommandOutput: false   # Specify whether the stderr output of the command should be redirected to the stdout stream 
                                        # and read by the integration server. Default is false.
    includeCommandOutputInLogs: true    # Specify whether the output from the command should appear in log and user trace messages. 
                                        # Default is true.
    #stopServerOnError: true            # Specify whether the server stops if script returns a non-zero exit code. Default is true.
In this example, the script /tmp/myscript.sh is run when the independent integration server starts. This script contains the following logic, which uses curl to copy the files needed for a policy override from a GitHub repository into an overrides directory:

mkdir /tmp/myworkdir/overrides/MQ
cd /tmp/myworkdir/overrides/MQ
curl -o .project https://raw.githubusercontent.com/jsmith/my-example-repo/main/MQ/.project
curl -o policy.descriptor https://raw.githubusercontent.com/jsmith/my-example-repo/main/MQ/policy.descriptor
curl -o MQ.policyxml https://raw.githubusercontent.com/jsmith/my-example-repo/main/MQ/MQ.policyxml
When the independent integration server starts, the following output is returned from the IntegrationServer command:
[jsmith@greys1 myworkdir]$ IntegrationServer --work-dir /tmp/myworkdir
2022-11-28 16:16:29.951740: BIP1990I: Integration server 'myworkdir' starting initialization; version '12.0.7.0' (64-bit)
2022-11-28 16:16:29.952722: BIP9560I: Script 'FirstScript' is about to run using command '/tmp/myscript.sh'.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   508  100   508    0     0   1587      0 --:--:-- --:--:-- --:--:--  1592
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   245  100   245    0     0    696      0 --:--:-- --:--:-- --:--:--   694
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   712  100   712    0     0   2131      0 --:--:-- --:--:-- --:--:--  2138
2022-11-28 16:16:31.108048: BIP9565I: Script 'FirstScript' has run successfully.
2022-11-28 16:16:31.122500: BIP9905I: Initializing resource managers.
2022-11-28 16:16:37.920092: BIP9906I: Reading deployed resources.
2022-11-28 16:16:37.922364: BIP9907I: Initializing deployed resources.
2022-11-28 16:16:38.810972: BIP2866I: IBM App Connect Enterprise administration security is inactive.
2022-11-28 16:16:38.826016: BIP3132I: The HTTP Listener has started listening on port '7600' for 'RestAdmin http' connections.
2022-11-28 16:16:38.830832: BIP1991I: Integration server has finished initialization.

Procedure

To configure an independent integration server to use a startup script, complete the following steps:

  1. Open the server.conf.yaml file for your independent integration server in a YAML editor. You can edit the file by using the built-in YAML editor that is provided in the IBM App Connect Enterprise Toolkit, either by double-clicking the file in the Application Development view or by right-clicking the file and selecting Open with > YAML editor.
  2. The StartupScripts section includes a template startup script configuration that is called FirstScript, which you can use to define scripts that run when the independent integration server starts. You can rename the FirstScript section and add additional sections (with different names) if multiple scripts are required. Ensure that you uncomment the lines that you want to include, by removing the # from the beginning of each required line.
  3. Set the command property to specify the file path of the script that you want to run when the independent integration server starts. For example:
    
     command: '/tmp/myscript.sh'
      
  4. When a command is run from the StartupScripts section of the server.conf.yaml file, it can generate output, which can then be used as part of the independent integration server configuration. You can use the readVariablesFromOutput property to control whether the independent integration server reads the output of commands that are run by the startup script. You can set this property to true, false, or auto (the default).
    If the readVariablesFromOutput property is set to true, the command output is parsed to look for configuration information, such as environment variables and user variables. For example:
    readVariablesFromOutput: true

    Commands in a startup script can create output in the form of YAML files. As part of its processing, the startup script can take the content of the output YAML file and use it to modify the independent integration server configuration. If the readVariablesFromOutput property is set to auto, the command output is scanned to see whether the first three characters are dashes (---), indicating the start of a YAML document. If they are, the rest of the YAML in the output is parsed.

    To be processed as part of the independent integration server configuration, output YAML created by the startup script must begin with three dashes (---), and it can contain sections that specify EnvironmentVariables, UserVariables, and env. The EnvironmentVariables and UserVariables sections must be in the format that is used to specify these properties in the server.conf.yaml file, and the env property is in the format that is used to set environment variables in Kubernetes. For example:
    ---
    env:
    - name: 'test1'
      value: 'test1value'
    UserVariables:
      user-var-one: 'uservalueone'
    EnvironmentVariables:
      env-var-one: 'envvalueone'
  5. Set the directErrorToCommandOutput property to specify whether the standard error (STDERR) output of the command is redirected to the standard output (STDOUT) stream and read by the independent integration server. The default value is false. For example:
    directErrorToCommandOutput: false
  6. Set the includeCommandOutputInLogs property to specify whether the output from the command appears in log and user trace messages. The default value is true. For example:
    includeCommandOutputInLogs: true
  7. Set the stopServerOnError property to specify whether the server stops if the script returns an error (a non-zero exit code). The default value is true.
  8. Restart the independent integration server. The properties that you set in the server.conf.yaml file take effect when the independent integration server is started. If you modify these properties again, you must also start the integration server again for the subsequent changes to take effect. For more information, see Starting an integration server.