Running Triggers as a Service

You can run your ARDI Trigger script as a service in Windows and as a daemon in Linux.

Make sure you finish your script with a call to Interactive rather than Start or Backfill.

Call your script with the –last parameter, specifying the path to a file that the system uses to record the most recent update. Ensure that this file can be written to and read by the user your service/daemon will run as.

Windows

In Windows, you can launch your program using NSSM, which is included in the /drivers/ folder of your ARDI installation.

Ensure you place double-quotes around any path names - spaces can cause problems.

Remember that the actual application you're running is Python - the name of the script is the first parameter to the Python executable.

Some platforms will require you to include the “.exe” after the Python path.

Linux

Create a new systemd unit file, filling in the description and path as required.

Copy this file into your systemd configuration directory - usually /etc/systemd/system.

[Unit]
Description = <Your service description here>
After = network.target 
 
[Service]
Type = simple
ExecStart = python <Path of the script you want to run> --last <Path to a read/write text file>
User = #Enter a user name here
Group = #Enter a group name here
Restart = on-failure
SyslogIdentifier = <Name of logs for the service>
RestartSec = 5
TimeoutStartSec = infinity
 
[Install]
WantedBy = multi-user.target

Enable the service with the following commands…

systemctl enable <service file name without .service extension>
systemctl daemon-reload
systemctl start <service file name without .service extension>