25 lines
534 B
Desktop File
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
|
|
|