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

25 lines
592 B
SYSTEMD
Raw Normal View History

2015-05-08 14:05:11 +00:00
[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
2015-09-06 12:18:17 +00:00
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; \
2015-05-08 14:05:11 +00:00
etcdctl --peers 172.17.42.1:4001 set /services/web/%i \'{"ip":"\'$ip\'", "port":"80"}\';'
ExecStop=-/usr/bin/etcdctl rm /services/web/%i