compose-website/unit-files/web@.service
2015-02-16 16:39:31 +00:00

36 lines
1.1 KiB
Desktop File

[Unit]
Description=%p-%i
# Requirements
Requires=docker.service
Requires=backup@%i.timer
# Dependency ordering
After=docker.service
Before=backup@%i.timer
[Service]
Restart=always
RestartSec=20
TimeoutStartSec=0
Type=notify
NotifyAccess=all
EnvironmentFile=/data/domains/%i/.env
Environment=URL=%i
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker
ExecStartPre=-/usr/bin/docker kill %i
ExecStartPre=-/usr/bin/docker rm %i
ExecStartPre=/bin/cp /data/domains/%i/TLS/%i.pem /data/runtime/haproxy/approved-certs/%i.pem
ExecStart=/bin/bash -euxc ' \
/opt/bin/systemd-docker --env run \
--rm \
--name %i \
-v /data/runtime/domains/%i/log/apache2:/var/log/apache2 \
${DOCKER_ARGUMENTS} \
pierreozoux/${APPLICATION}'
ExecStartPost=/bin/bash -c ' \
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' %i`; \
/usr/bin/etcdctl --peers 172.17.42.1:4001 set /services/web/%i \'{"ip":"\'$ip\'", "port":"80"}\'
ExecStop=/usr/bin/docker stop %i
ExecStopPost=-/usr/bin/etcdctl --peers 172.17.42.1:4001 rm /services/web/%i