diff --git a/deployment/systemd/README.md b/deployment/systemd/README.md new file mode 100644 index 000000000..044b86f21 --- /dev/null +++ b/deployment/systemd/README.md @@ -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 \ No newline at end of file diff --git a/deployment/systemd/env b/deployment/systemd/env new file mode 100644 index 000000000..c263a0783 --- /dev/null +++ b/deployment/systemd/env @@ -0,0 +1 @@ +SEMPAPHORE_CONFIG=/etc/semaphore/config.json \ No newline at end of file diff --git a/deployment/systemd/semaphore.service b/deployment/systemd/semaphore.service new file mode 100644 index 000000000..31d910a4e --- /dev/null +++ b/deployment/systemd/semaphore.service @@ -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 \ No newline at end of file diff --git a/deployment/systemd/util/install.sh b/deployment/systemd/util/install.sh new file mode 100755 index 000000000..f606e650c --- /dev/null +++ b/deployment/systemd/util/install.sh @@ -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 \ No newline at end of file diff --git a/deployment/systemd/util/uninstall.sh b/deployment/systemd/util/uninstall.sh new file mode 100755 index 000000000..ae5845004 --- /dev/null +++ b/deployment/systemd/util/uninstall.sh @@ -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 \ No newline at end of file