[Unit]
Description=6Si Front End Service
Requires=mysql.service
After=mysql.service
[Service]
RestartSec=10s
# Ensure ntropy DB is loaded before starting ui
ExecStartPre=/home/core/share/scripts/admin restore_mysql ntropy
ExecStart=/usr/bin/docker run \
--cidfile=/var/run/%n.cid \
-rm \
-dns 172.12.8.150 \
-e DEBUG=TRUE \
-e DB_NAME=ntropy \
-e DB_USER=root \
-e DB_PASSWORD= \
-p 80:8000 \
-link mysql:db \
sixsense/ui
ExecStop=/bin/bash -c "/usr/bin/docker stop $(cat /var/run/%n.cid)"
ExecStop=/bin/rm /var/run/%n.cid
[Install]
WantedBy=local.target
----
This kind of works though whenever I run systemctl stop, systemd claims the process failed and immediately tries to restart it. The Exec commands are all exiting with return codes of 0.
However,this seems counterintuitive to me. Shouldn't calling docker run without the the '-d' keep the process in the foreground. Shouldn't systemd then kill the docker container for me when I call systemctl stop without me needing to have an explicit script.