From 59c23a9132078b0577c7dc953c8243b69a451b42 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 29 Nov 2017 07:17:48 -0500 Subject: [PATCH] ws.server@.service: service to launch the .jar websocket server and restart it on fail/stop + install.sh: installs the service into 'systemd' + uninstall.sh: uninstalls all from 'systemd' --- install.sh | 14 ++++++++++++++ uninstall.sh | 11 +++++++++++ ws.server@.service | 12 ++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 install.sh create mode 100644 uninstall.sh create mode 100755 ws.server@.service diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..c5a7c41 --- /dev/null +++ b/install.sh @@ -0,0 +1,14 @@ +#!/bin/bash + + +# (1) Copy the systemd service file +sudo cp /opt/ws.server/ws.server@.service /lib/systemd/system/ws.server@.service; + +# Note: cannot create a symlink, it will be too much link level +#sudo ln -s /opt/ws.server/ws.server@.service /lib/systemd/system/ws.server@.service; + +# (2) Reload systemctl daemon to manage the new service +sudo systemctl daemon-reload; + +# (3) Enable /opt/ws.server/ndli1718.jar to be executed at startup + restart on fail +sudo systemctl enable ws.server@ndli1718.service; diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..04e7cec --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,11 @@ +#!/bin/bash + + +# (1) disable /opt/ws.server/ndli1718.jar +sudo systemctl disable ws.server@ndli1718.service; + +# (2) Remove the service from systemd +sudo rm /lib/systemd/system/ws.server@.service; + +# (3) Reload systemctl +sudo systemctl daemon-reload; diff --git a/ws.server@.service b/ws.server@.service new file mode 100755 index 0000000..cbd9795 --- /dev/null +++ b/ws.server@.service @@ -0,0 +1,12 @@ +[Unit] +Description=WebSocket Server [%i] +Before=network-pre.target +Wants=network-pre.target + +[Service] +Type=simple +Restart=always +ExecStart=/usr/bin/env java -jar /opt/ws.server/%i.jar + +[Install] +WantedBy=multi-user.target