Skip to content

Instantly share code, notes, and snippets.

@rosskukulinski
Last active March 7, 2018 03:23
Show Gist options
  • Save rosskukulinski/96f7709fa20d7def6b9e to your computer and use it in GitHub Desktop.
Save rosskukulinski/96f7709fa20d7def6b9e to your computer and use it in GitHub Desktop.
[Unit]
Description=App Redis Sidekick
Requires=docker.service
Requires=etcd.service
After=docker.service
After=etcd.service
After=app-redis.service
BindsTo=app-redis.service
[Service]
EnvironmentFile=/etc/environment
User=core
TimeoutStartSec=0
ExecStart=/bin/bash -c '\
while true; do \
port=$(docker inspect --format=\'{{(index (index .NetworkSettings.Ports "6379/tcp") 0).HostPort}}\' app-redis.service); \
etcdctl set /services/app-redis/dfw ${COREOS_PRIVATE_IPV4}:$port --ttl 10; \
sleep 5; \
done'
ExecStop=/usr/bin/etcdctl rm /services/app-redis/dfw
[X-Fleet]
MachineOf=app-redis.service
[Unit]
Description=App Redis
After=docker.service
Requires=docker.service
Requires=app-redis-sk.service
[Service]
EnvironmentFile=/etc/environment
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker kill %n
ExecStartPre=-/usr/bin/docker rm %n
ExecStartPre=/usr/bin/docker pull redis
ExecStart=/usr/bin/docker run --name %n -p ${COREOS_PRIVATE_IPV4}::6379 redis:latest redis-server --requirepass XYZ1234
ExecStop=/usr/bin/docker stop %n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment