compose-website/unit-files/discovery@.service
2015-01-15 18:17:26 +01:00

25 lines
534 B
Desktop File

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