startmixonlinuxasaservice

Running MIX or a TransSECS Deployment on a Linux system as a service has the advantages that you can stop and start the application as needed, that the print() (console output) in scripts will be logged to the system log and that the service will automatically restart if it crashes for some reason (hopefully very rarely).

You can find more information on setting up and using systemd services, such as: https://linuxconfig.org/how-to-write-a-simple-systemd-service

Create a service configuration

In this example a configuration for starting mix is configured by creating a text file in the /lib/systemd/system directory. For this example, this is named “mix.service”. You will need to be logged in as root (sudo) to do this.

Create and edit mix.service so it contains this text:

[Unit]
Description=MIX Service
After=network.target
 
[Service]
#Type=simple
User=mix
ExecStart=/home/mix/mixruntime/runmix.sh
Restart=always
RestartSec=60
 
[Install]
WantedBy=multi-user.target

Use systemctl to enable the configuration at boot

On the command line, type:

systemctl enable mix

This registers and enables “mix.service”

You can start/stop/restart, etc with systemctl:

systemctl start mix

The configuration contains “Restart=always” so it will restart if the application stops.

  • startmixonlinuxasaservice.txt
  • Last modified: 2021/07/26 20:57
  • by wikiadmin