Skip to content
Snippets Groups Projects
discovery-u@.service 523 B
Newer Older
Pierre Ozoux's avatar
Pierre Ozoux committed
[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 -euxc ' \
  sleep 3; \
Pierre Ozoux's avatar
Pierre Ozoux committed
  container_name=`echo ${URL}_web_1 | sed "s/\.//g"`; \
Pierre Ozoux's avatar
Pierre Ozoux committed
  ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' $container_name`; \
  etcdctl --peers 172.17.42.1:4001 set /services/web/%i \'{"ip":"\'$ip\'", "port":"80"}\';'
ExecStop=-/usr/bin/etcdctl rm /services/web/%i