Skip to content

Instantly share code, notes, and snippets.

@bytesandwich
Created February 6, 2015 05:54
Show Gist options
  • Save bytesandwich/e8fdec303532d84b1646 to your computer and use it in GitHub Desktop.
Save bytesandwich/e8fdec303532d84b1646 to your computer and use it in GitHub Desktop.
postgres master announce
[Unit]
Description=Announce Postgres Master
BindsTo=postgres-master.service
After=postgres-master.service
[Service]
ExecStart=/bin/sh -c "while true; do etcdctl set /services/postgres/master '{ \"host\": \"%H\", \"port\": 80, \"version\": \"52c7248a14\", \"ip\": \"'`ifconfig docker0 | awk '/\<inet\>/ { print $2}'`'\" }' --ttl 60;sleep 45;done"
ExecStop=/usr/bin/etcdctl rm /services/postgres/master
[X-Fleet]
MachineOf=postgres-master.service
@popsikle
Copy link

popsikle commented Feb 6, 2015

[Unit]
Description=Announce Postgres Master
BindsTo=postgres-master.service
After=postgres-master.servicee

[Service]
EnvironmentFile=/etc/environment
ExecStart=/bin/bash -c 'while true; do PORT=`docker port postgres-master.service 5432 | cut -f2 -d:`; etcdctl set /services/postgres/master \'{"ip": "${COREOS_PRIVATE_IPV4}", "port": \'"$PORT"\' }\' --ttl 60; sleep 45; done'
ExecStop=/usr/bin/etcdctl rm /services/postgres/master

[X-Fleet]
MachineOf=postgres-master.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment