diff --git a/autocat3.service b/autocat3.service index 9adf218..80ae2aa 100644 --- a/autocat3.service +++ b/autocat3.service @@ -8,7 +8,15 @@ Type=simple RuntimeDirectory=autocat WorkingDirectory=/var/lib/autocat/autocat3 ExecStartPre=-/usr/bin/mkdir -p /var/run/autocat -ExecStart=/var/lib/autocat/.local/bin/pipenv run python CherryPyApp.py +ExecStart=/usr/local/bin/pipenv run python CherryPyApp.py +# +# These next lines are for auto-restart. See: man systemd.service +Type=simple +PIDFile=/var/run/autocat/autocat3.pid +RemainAfterExit=no +Restart=on-failure +RestartSec=5s +TimeStartSec=5s [Install] WantedBy=multi-user.target diff --git a/configuring.txt b/configuring.txt index ac9b095..1818581 100644 --- a/configuring.txt +++ b/configuring.txt @@ -67,6 +67,9 @@ sudo touch /var/run/autocat/autocat3.pid # Better to set the group name as pgweb for /var/run/autocat sudo chown -R autocat:pgweb /var/run/autocat +##### +##### To install or update the autocat3 service +##### sudo systemctl enable /var/lib/autocat/autocat3/autocat3.service sudo systemctl start autocat3 @@ -74,10 +77,10 @@ sudo systemctl start autocat3 # it might be due to monit (the monitoring system) fighting to restart. Or it might be that the # service is in an uncertain state, not stopped. Try: sudo service autocat3 stop -systemctl disable autocat3.service -systemctl enable /var/lib/autocat/autocat3/autocat3.service -systemctl restart autocat3.service -systemctl status autocat3.service +sudo systemctl disable autocat3.service +sudo systemctl enable /var/lib/autocat/autocat3/autocat3.service +sudo systemctl restart autocat3.service +sudo systemctl status autocat3.service # `sudo rm /etc/systemd/system/autocat3.service` is probably not needed. As of July 20 2019, # we are having problems with monit trying to restart. It might be necessary to also stop