compose-website/unit-files/discovery@.service

26 lines
534 B
SYSTEMD
Raw Normal View History

2014-11-18 22:38:40 +00:00
[Unit]
Description=%p for %i etcd registration
# Requirements
Requires=etcd.service
2015-01-15 17:17:26 +00:00
# Dependency binding
BindsTo=web@%i.service
2014-11-18 22:38:40 +00:00
[Service]
ExecStart=/bin/bash -c ' \
sleep 30; \
while true; do \
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' %i`; \
2014-11-18 22:38:40 +00:00
curl -f $ip; \
if [ $? -eq 0 ]; then \
2015-01-11 19:04:01 +00:00
etcdctl set /services/web/%i \'{"ip":"\'$ip\'", "port":"80"}\' --ttl 60; \
2014-11-18 22:38:40 +00:00
else \
2015-01-11 19:04:01 +00:00
etcdctl rm /services/web/%i; \
2014-11-18 22:38:40 +00:00
fi; \
sleep 50; \
done'
ExecStop=-/usr/bin/etcdctl rm /services/web/%i