Skip to content
Snippets Groups Projects
Commit c4d32cf8 authored by Pierre Ozoux's avatar Pierre Ozoux
Browse files

No more universal services \o/

parent 77e9d021
No related branches found
No related tags found
No related merge requests found
[Unit]
Description=Back up data from %i
[Service]
Type=oneshot
TimeoutStartSec=3000
WorkingDirectory=/data/domains/%i/
EnvironmentFile=/etc/environment
ExecStartPre=-/bin/docker kill clean-%i
ExecStartPre=-/bin/docker rm clean-%i
ExecStartPre=-/bin/docker kill backup-%i
ExecStartPre=-/bin/docker rm backup-%i
ExecStartPre=/bin/bash -euxc ' \
/bin/docker run \
--rm \
--name clean-%i \
-e PASSPHRASE \
-v /root:/root \
indiepaas/duplicity \
remove-older-than 10D \
sftp://${BACKUP_DESTINATION}//data/%i'
ExecStartPre=/bin/bash -euxc '/data/domains/%i/BACKUP'
ExecStart=/bin/bash -euxc ' \
/bin/docker run \
--rm \
--name backup-%i \
-e PASSPHRASE \
-h backup.container \
--cpu-shares=40 \
-e PASSPHRASE \
-v /dev/random:/dev/random \
-v /dev/urandom:/dev/urandom \
-v /root:/root \
-v /data/domains/%i:/backup indiepaas/duplicity \
--volsize 500 \
--full-if-older-than 7D \
--asynchronous-upload \
--encrypt-key ${ENCRYPT_KEY} \
/backup \
sftp://${BACKUP_DESTINATION}//data/%i'
[Unit]
Description=Hourly backup of www and mysql content.
# Dependency binding
BindsTo=universal@%i.service
[Timer]
OnActiveSec=20
OnUnitActiveSec=60min
AccuracySec=50min
[Unit]
Description=%p for %i etcd registration
# Requirements
Requires=etcd.service
# Dependency binding
BindsTo=universal@%i.service
[Service]
Type=oneshot
RemainAfterExit=yes
Environment=URL=%i
ExecStart=/bin/bash -xc ' \
ip=""; \
while [ -z $ip ]; \
do \
container_name=`echo ${URL}_web_1 | sed "s/\.//g" | sed "s/-//g"`; \
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' $container_name`; \
sleep 1; \
done; \
etcdctl --peers 172.17.42.1:4001 set /services/web/%i \'{"ip":"\'$ip\'", "port":"80"}\';'
ExecStop=-/usr/bin/etcdctl rm /services/web/%i
[Unit]
Description=%p-%i
# Requirements
Requires=docker.service
Requires=discovery-u@%i.service
Requires=backup-u@%i.timer
# Dependency ordering
After=docker.service
Before=discovery-u@%i.service
Before=backup-u@%i.timer
[Service]
Restart=always
RestartSec=10
TimeoutStartSec=60
TimeoutStopSec=15
WorkingDirectory=/data/domains/%i/
ExecStartPre=/bin/cp /data/domains/%i/TLS/%i.pem /data/runtime/haproxy/approved-certs/%i.pem
ExecStart=/bin/bash -euxc '/data/domains/%i/RUN'
ExecStop=/bin/bash -euxc '/data/domains/%i/STOP'
[Install]
WantedBy=multi-user.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment