How to leverage Linux systemctl to start/stop Iguana
Iguana Admin using Linux (CentOS, RedHat) want to use the linux system manager (systemd) to start/stop/reset their Iguana instances. To take advantage of ‘systemd’, the use of ‘systemctl’ to interact and configure ‘systemd’ is necessary. To use ‘systemctl' to configure 'systemd’, the use of the following script (Code Demo) is needed to start/stop/reset Iguana with descriptions of each command used (Design).
Design
In the design, the use of a .service file is needed to allow ‘systemctl’ to configure ‘systemd’. The options specific to the [Service] section that are used are the following:
Type: Configures the process start-up type for this service unit.
User: 'root' is used below but this depends on which user you run iguana on.
Restart: Configures whether the service shall be restarted when the service process exits, is killed, or a timeout is reached.
RestartSec: Configures the time to sleep before restarting a service (as configured with
Restart=
).ExecStart: Commands with their arguments that are executed when this service is started.
ExecStop: Commands to execute to stop the service started via
ExecStart=
.Working Directory: Iguana Configuration folder (include Iguana license, Iguana channel info…).
Code Demo
This is sample code that was configured to run on Linux CentOS 7.
my-startup.service File:
[Unit]
Description=Iguana service
After=network-online.target
[Service]
Type=simple
User=root
Restart=always
RestartSec=9
WorkingDirectory=/mnt/iguanas/iguana615/working_dir
ExecStart=/mnt/iguanas/iguana615/iNTERFACEWARE-Iguana/iguana --run
ExecStop=kill -15 `cat /mnt/iguanas/iguana615/iNTERFACEWARE-Iguana/Iguana.pid`
[Install]
WantedBy=multi-user.target
Consideration
Sometimes the working directory does not initialize using the ‘WorkingDirectory=' command. The working directory can be initialized using the following code snippet for 'ExecStart=’ while deleting the line 10 in the Code Demo:
ExecStart=/mnt/iguanas/iguana615/iNTERFACEWARE-Iguana/iguana --run --working_dir /mnt/iguanas/iguana615/working_dir
Â