2014-10-05 09:54:36 +00:00
|
|
|
[Unit]
|
|
|
|
Description=%p-%i
|
2014-10-27 12:32:21 +00:00
|
|
|
|
|
|
|
# Requirements
|
2014-10-05 09:54:36 +00:00
|
|
|
Requires=docker.service
|
2015-01-11 19:04:01 +00:00
|
|
|
Requires=init@%i.service
|
2015-01-12 09:18:35 +00:00
|
|
|
Requires=discovery@%i.service
|
2014-11-04 16:04:55 +00:00
|
|
|
Requires=backup@%i.timer
|
2014-10-27 12:32:21 +00:00
|
|
|
|
|
|
|
# Dependency ordering
|
|
|
|
After=docker.service
|
2015-01-11 19:04:01 +00:00
|
|
|
After=init@%i.service
|
2015-01-12 09:18:35 +00:00
|
|
|
Before=discovery@%i.service
|
2015-01-11 19:04:01 +00:00
|
|
|
Before=backup@%i.timer
|
|
|
|
|
2014-10-05 09:54:36 +00:00
|
|
|
[Service]
|
|
|
|
Restart=always
|
2015-01-12 09:18:35 +00:00
|
|
|
EnvironmentFile=/data/domains/%i/.env
|
|
|
|
ExecStartPre=-/usr/bin/docker kill %i
|
|
|
|
ExecStartPre=-/usr/bin/docker rm %i
|
2015-01-11 19:04:01 +00:00
|
|
|
ExecStartPre=/bin/bash -euxc ' \
|
2015-01-12 09:18:35 +00:00
|
|
|
application_folder=/data/domains/%i/%p/www-content; \
|
2015-01-11 19:04:01 +00:00
|
|
|
if [ ! -d $application_folder ]; then \
|
|
|
|
mkdir -p $application_folder; \
|
|
|
|
echo Hello %i > $application_folder/index.html; \
|
2015-01-12 09:18:35 +00:00
|
|
|
fi'
|
2015-01-11 19:04:01 +00:00
|
|
|
|
2014-10-27 12:32:21 +00:00
|
|
|
ExecStart=/usr/bin/docker run \
|
2015-01-12 09:18:35 +00:00
|
|
|
--name %i \
|
2014-11-04 19:16:15 +00:00
|
|
|
-v /data/domains/%i/%p/www-content:/app \
|
2015-01-05 16:35:46 +00:00
|
|
|
pierreozoux/nginx
|
2015-01-12 09:18:35 +00:00
|
|
|
ExecReload=/bin/bash -euxc ' \
|
|
|
|
/usr/bin/docker restart %i; \
|
|
|
|
systemctl restart discovery@%i.service; \
|
|
|
|
systemctl restart backup@%i.timer;'
|
|
|
|
ExecStop=/bin/bash -euxc ' \
|
|
|
|
systemctl stop init@%i.service; \
|
|
|
|
systemctl stop discovery@%i.service; \
|
|
|
|
systemctl stop backup@%i.timer; \
|
|
|
|
/usr/bin/docker stop %i;'
|
2014-10-05 09:54:36 +00:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|