systemd example

This commit is contained in:
tom whiston 2018-04-06 20:14:50 +00:00
parent 1a9ae22382
commit cca5d8fbcf
5 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,12 @@
# Systemd
This is a sample systemd unit and environment file that you could use to run Semaphore with.
It makes no assumptions about running proxies or databases on the same machine,
therefore if you do this you may wish to add addition requirements to the unit.
The unit will write logs to the journal which you can read with
`journalctl -u semaphore.service`
Example install, and for convenience uninstall, scripts are located in the util subdir.
The scripts expect that you manually install semaphore in /usr/bin and have the config file
/etc/semaphore/config.json. The config file location can be altered via the env file,
which the script installs as /etc/semaphore/env

1
deployment/systemd/env Normal file
View File

@ -0,0 +1 @@
SEMPAPHORE_CONFIG=/etc/semaphore/config.json

View File

@ -0,0 +1,14 @@
[Unit]
Description=Ansible Semaphore
Requires=network.target
[Service]
EnvironmentFile=/etc/semaphore/env
ExecStart=/usr/bin/semaphore -config ${SEMAPHORE_CONFIG}
User=semaphore
Group=semaphore
Restart=always
RestartSec=3s
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
mkdir -p /etc/semaphore
cp ${HERE}/../semaphore.service /etc/systemd/system
cp ${HERE}/../env /etc/semaphore/env
systemctl start semaphore.service

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e
systemctl stop semaphore.service
systemctl disable semaphore.service
rm /etc/systemd/system/semaphore.service
rm -rf /etc/semaphore