Feature #5350
closedredux systemd service
0%
Description
This provides service that works on CentOS7 and above and other OS such as Ubuntu.
Updated by Patrick Goetz almost 6 years ago
I just noticed this task was assigned to me. I think I've already provided an answer in the forum, but here is a very simple systemd unit file which works for Ubuntu systems:
/etc/systemd/system/reduxd.service:
[Unit] Description=Redux Image Server After=apache2.service [Service] Type=simple User=root Group=root PrivateTmp=true WorkingDirectory=/usr/local/bin ExecStart=/usr/local/bin/reduxd [Install] WantedBy=multi-user.target
A similar unit file (not tested) should work for CentOS systems. The only difference is that the Apache httpd service is called httpd.service on CentOS systems, so the presumed service file would be this:
/etc/systemd/system/reduxd.service:
[Unit] Description=Redux Image Server After=httpd.service [Service] Type=simple User=root Group=root PrivateTmp=true WorkingDirectory=/usr/local/bin ExecStart=/usr/local/bin/reduxd [Install] WantedBy=multi-user.target
Any other changes (say running the service as something other than root, for example) should be self-explanatory. However, systemd allows for a lot of interesting features. For example, to have the reduxd server restart automatically whenever it crashes or is killed, one can modify the service file like this:
/etc/systemd/system/reduxd.service:
[Unit] Description=Redux Image Server After=httpd.service [Service] Type=simple Restart=always RestartSec=1 User=root Group=root PrivateTmp=true WorkingDirectory=/usr/local/bin ExecStart=/usr/local/bin/reduxd [Install] WantedBy=multi-user.target
The Restartsec field specifies that the service should sleep for one second before restarting.