Configuring a Station to Run as a Service

You can run a script to create the configuration file that enables you to run a station as a service.

This task shows you how to:

Configure a Station to Run as a Windows Service

  1. Open a Windows command prompt, and from the 3DOrchestrate root directory, run the following:

    .\code\command\SMAExeStationAsService-Configure.bat profile:<PROFILE NAME> name:<STATION NAME> account:<SERVICE ACCOUNT>
    The profile specifies a connection profile name (without the .cpr extension); the name is the station name as you like it to appear in the 3DOrchestrate server; and the account is the Windows user account that owns the station as a service.

    All three arguments are optional. However, if you include them when you run the script, you can add them to the configuration file and prepopulate their values whenever you use the station as a service.

    The configuration script displays a summary of the options in the service that it creates.
  2. Review the summary, particularly the %TEMP% directory where the system stores the log and temporary files associated with the station as a service. If the options are satisfactory, press Y to perform the configuration.
    The script creates a configuration file in the /config folder under the 3DOrchestrate root directory.

    If you define the environment variables CAT_ENV_FILE and CAT_ENV_PATH, the Station Windows Service can access every CATEnv parameter that is present in the service file.

Configuring a Station to Run as a Linux Service

  1. Log on to the Linux server as the user that runs the service, and confirm that the user account has sufficient permissions to run the configuration scripts.
  2. Run the following command:

    InstallPath/linux_a64/code/command/StationAsAService-config {-c} path-to-cpr-file service-name

    Where the -c parameter configures the Service to use CATSTART to start the station, which ensures that the station uses the CATEnv parameters. path-to-cpr-file is the location of the .cpr file for the server login profile (usually InstallPath/config), and service-name is an optional parameter that lets you create the station as a service with a custom name. If you do not specify the station as a service name, it creates the station as a service using the default name, SMAExeStation.

    When StationAsAService-config runs to completion, it creates a .service file.
  3. Review the contents of the newly created .service file to confirm that the values are correct. A sample .service file appears in Sample Unit File for Linux to illustrate the file's syntax. Do the following to verify that the station is configured correctly:
    1. Start the station as the desired user, before running as a service, to make sure the user can run the station without errors.

      In this context, "user" refers to the user who executes the service. By default, the configuration uses the user who created the service file. If required change the desired user, and validate that the user has the proper permissions to read and write to the station log and scratch directories.

    2. Open the .servicefile in a text editor, and increase the value of SMAEXE_MEM if you want to allot more than 2 GB of memory to it.
  4. If the .service file is correct, move it to /etc/system/systemd.
  5. To apply changes to the service file or any station property, stop, reload, and start the service.

Sample Unit File for Linux

[Unit]
Description=Station as service on Linux
After=network.target
[Service]
User=<userThatRunsStation>
Environment=SMAEXE_HOME={InstallPath}/linux_a64
Environment=SMAEXE_CONF={InstallPath}/linux_a64/../config
Environment=SMAEXE_JRE={Java_Path}
Environment=SMAEXE_MEM=2G
ExecStart={InstallPath}/linux_a64/code/command/SMAExeStation 
logonprompt:no user:fiperstation pw:fiperstation profile:<ProfileFile> name:<ServiceStationName> nogui:true
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
Example: Sample Service File with -c Flag Used
[Unit]
Description=Station as service on Linux
After=network.target
[Service]
User=<userThatRunsStation>
Environment=SMAEXE_HOME={InstallPath}/linux_a64
Environment=SMAEXE_CONF={InstallPath}/linux_a64/../config
Environment=SMAEXE_JVMPARMS=
Environment=SMAEXE_MEM=2G
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
ExecStart={InstallPath}/linux_a64/code/bin/CATSTART -e Env.txt
-direnv {InstallPath}/CATEnv -run 
{InstallPath}/linux_a64/code/command/SMAExeStation 
logonprompt:no user:fiperstation pw:fiperstation 
profile:<ProfileFile> name:<ServiceStationName> nogui=true"
[Install]
WantedBy=multi-user.target