From 1314b3ab759eec8414c605cf441b8e69572b08be Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 27 Dec 2018 14:05:40 +0000 Subject: [PATCH] Update service files etc. --- rhinoreminds.service | 53 +++++++++++++++++++++++++++++++++++++++----- start_service.sh | 12 ++++++---- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/rhinoreminds.service b/rhinoreminds.service index e3226d5..cc5a1f4 100644 --- a/rhinoreminds.service +++ b/rhinoreminds.service @@ -2,15 +2,58 @@ Description=RhinoReminds XMPP Bot After=network.target prosody.service +# No more than 5 crashes in 12 hours +StartLimitIntervalSec=43200 +StartLimitBurst=5 + [Service] -Type=simple -# Another Type option: forking -User=rhinoreminds -WorkingDirectory=/srv/rhinoreminds -ExecStart=/srv/rhinoreminds/start_service.sh +Type=forking +PIDFile=/run/rhinoreminds.pid +# We change our own user +User=root +WorkingDirectory=/srv/kraggwapple +ExecStart=/srv/kraggwapple/start_service.sh Restart=on-failure # Other Restart options: or always, on-abort, etc +# Delay restarts by 60 seconds +RestartSec=60 [Install] WantedBy=multi-user.target + + + + + + + + + +[Unit] +Description=Kraggwapple XMPP Bot +After=network.target prosody.service + +# No more than 5 crashes in 12 hours +StartLimitIntervalSec=43200 +StartLimitBurst=5 + +[Service] +Type=forking +PIDFile=/run/kraggwapple.pid +# We change our own user +User=root +WorkingDirectory=/srv/kraggwapple +ExecStart=/srv/kraggwapple/start_service.sh +Restart=on-failure +# Other Restart options: or always, on-abort, etc +# Delay restarts by 60 seconds +RestartSec=60 + +[Install] +WantedBy=multi-user.target + + + + + diff --git a/start_service.sh b/start_service.sh index c75201b..b8d9c98 100755 --- a/start_service.sh +++ b/start_service.sh @@ -1,8 +1,12 @@ #!/usr/bin/env bash -source .xmpp_credentials +cd data; +source .xmpp_credentials; -export XMPP_JID; -export XMPP_PASSWORD; +# Execute & disown +# We pass the environment variables explicitly here, as then we don't accidentally pass something private. +# Better to be safe than sorry - defence in depth! +sudo -u username_here XMPP_JID="${XMPP_JID}" XMPP_PASSWORD="${XMPP_PASSWORD}" /usr/bin/mono RhinoReminds.exe --domain starbeamrainbowlabs.com +echo "$!" >/run/rhinoreminds.pid; +disown; -exec /usr/bin/mono RhinoReminds.exe --domain starbeamrainbowlabs.com