Skip to content

Commit

Permalink
systemd example
Browse files Browse the repository at this point in the history
  • Loading branch information
twhiston committed Apr 6, 2018
1 parent 1a9ae22 commit cca5d8f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions deployment/systemd/README.md
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions deployment/systemd/env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SEMPAPHORE_CONFIG=/etc/semaphore/config.json
14 changes: 14 additions & 0 deletions deployment/systemd/semaphore.service
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions deployment/systemd/util/install.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions deployment/systemd/util/uninstall.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cca5d8f

Please sign in to comment.