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.

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="NTX86" startCmd="setup" timeout="600" successCodes="0,1,2"/>
            </osTypes>
        </install>    
        <uninstall>
           <osTypes>
              <osType name="NTX86" 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="NTX86" startCmd="cmd /c 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 top level of the service package—it cannot be in a subdirectory.

  6. Deploy the service package.
    1. In the Platform Management Console, select Manage Service Packages > Global Actions > Add Package to Repository.

      The Add Package to respository page displays.

    2. Browse to your service package and select it.
    3. Select the application associated with your service package, then Add.

      Your service package should now be displayed in the list.

    Note:

    You can also use the following commands:

    soamdeploy add SampleService -p SampleService.exe.gz -c /SampleApplications/SOASamples

    soamdeploy view -c /SampleApplications/SOASamples

Linux/UNIX 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 deployment.xml are case-sensitive when the service is deployed on Linux/UNIX.

  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 top level of the service package—it cannot be in a subdirectory.

  6. Deploy the service package.
    1. In the Platform Management Console, select Manage Service Packages > Global Actions > Add Package to Repository.

      The Add Package to respository page displays.

    2. Browse to your service package and select it.
    3. Select the application associated with your service package, then 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