Automatically run a command when deploying a service package

Suppose your service uses a third-party tool and it needs to be installed on the compute host, or you want to run a script to perform some actions for proper functioning of the service program. You can configure this in a package-specific deployment.xml configuration file.

Procedure

  1. Automatically run a command when deploying a Windows service package:
    1. Create a file for your service package with the name deployment.xml.

      The file must be called deployment.xml.

      For example:
      <Deployment xmlns="http://www.platform.com/Symphony/Deployment">
           <install>
              <osTypes>  
                <osType name="NTX64" startCmd="setup" timeout="600" successCodes="0,1,2"/>
              </osTypes>
           </install>    
           <uninstall>
              <osTypes>
                <osType name="NTX64" startCmd="setup -u" timeout="30" successCodes="0"/> 
              </osTypes>
          </uninstall>
      </Deployment>
      
      Note: To run a Windows .bat script, you need to specify a special syntax. For example:
      <osType name="NTX64" startCmd="cmd /c install.bat" timeout="600" successCodes="0,1,2"/>
      
    2. Use the install section to configure the command to run after the package is uncompressed on a compute host.
    3. For startCmd, specify a path relative to the service package installation directory.

      For example, if your package contained a subdirectory called scripts with the command you want to invoke called myscript, specify:

      startCmd="scripts\myscript"

    4. Use the uninstall section to configure the command to run if the startCmd specified in the install section fails, or before the package is removed from a compute host.
    5. Add deployment.xml to your service package with the executables for the commands you specified in StartCmd.
      Important: There can only be one deployment.xml file per service package. The file must be at the beginning of the service package; it cannot be in a subdirectory.
    6. Deploy the service package.
      1. In the cluster management console, select Resources > Service Packages > Service Packages > Global Actions > Add package to repository.

        The Add Package to repository page displays.

      2. Browse to your service package and select it.
      3. Click Add.

        Your service package should now be displayed in the list.

        Note: You can also use the soamdeploy command:
        soamdeploy add SampleService -p SampleService.exe.gz -c 
        /SampleApplications/SOASamples
        soamdeploy view -c /SampleApplications/SOASamples
  2. Automatically run a command when deploying a Linux® service package:
    1. Create a file for your service package with the name deployment.xml.

      The file must be called deployment.xml.

      For example:

      <Deployment xmlns="http://www.platform.com/Symphony/Deployment">
          <install>
             <osTypes>
                <osType name="LINUX86" startCmd="setup" timeout="600" successCodes="0,1,2"/>  
             </osTypes>
          </install>
          <uninstall>
             <osTypes>
                <osType name="LINUX86" startCmd="setup -u" timeout="30" successCodes="0"/>   
             </osTypes>
         </uninstall>
      </Deployment>
      
      Note: All values in the deployment.xml file are case-sensitive when the service is deployed on Linux.
    2. Use the install section to configure the command to run after the package is uncompressed on a compute host.
    3. For startCmd, specify a path relative to the service package installation directory.
      For example, if your package contained a subdirectory called scripts with the command you want to invoke called myscript, specify:
      startCmd="scripts/myscript"
      
    4. Use the uninstall section to configure the command to run if the startCmd specified in the install section fails, or before the package is removed from a compute host.
    5. Add deployment.xml to your service package with the executables for the command you specified in StartCmd.
      Important: There can only be one deployment.xml file per service package. The file must be at the beginning of the service package; it cannot be in a subdirectory.
    6. Deploy the service package.
      1. In the cluster management console, select Resources > Service Packages > Service Packages > Global Actions > Add package to repository.

        The Add Package to repository page displays.

      2. Browse to your service package and select it.
      3. Click Add.

        Your service package should now be displayed in the list.

      Note: You can also use the following commands:
      soamdeploy add SampleService -p SampleService.tar.gz -c /SampleApplications/SOASamples
      soamdeploy view -c /SampleApplications/SOASamples