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'

This commit is contained in:
xdrm-brackets 2017-11-29 07:17:48 -05:00
commit 59c23a9132
3 changed files with 37 additions and 0 deletions

14
install.sh Normal file
View File

@ -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;

11
uninstall.sh Normal file
View File

@ -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;

12
ws.server@.service Executable file
View File

@ -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