Skip to content

Instantly share code, notes, and snippets.

@kerin
Created April 22, 2015 10:01
Show Gist options
  • Save kerin/8a0259cc58386e9f4f5a to your computer and use it in GitHub Desktop.
Save kerin/8a0259cc58386e9f4f5a to your computer and use it in GitHub Desktop.
[Unit]
Description=PostgreSQL server discovery service
# Requirements
Requires=etcd.service
Requires=docker.service
Requires=postgres.service
# Dependency ordering
After=etcd.service
After=docker.service
After=postgres.service
BindsTo=postgres.service
[Service]
# Let processes take awhile to start up (for first run Docker containers)
TimeoutStartSec=0
# Change killmode from "control-group" to "none" to let Docker remove
# work correctly.
KillMode=none
# Get CoreOS environmental variables
EnvironmentFile=/etc/environment
# Pre-start and Start
## Directives with "=-" are allowed to fail without consequence
ExecStartPre=-/usr/bin/docker kill postgres-discovery-vis.1
ExecStartPre=-/usr/bin/docker rm postgres-discovery-vis.1
ExecStartPre=/usr/bin/docker pull quay.io/mojvis/vis-postgres-discovery
ExecStart=/usr/bin/docker run --name postgres-discovery-vis.1 \
-e "COREOS_PRIVATE_IPV4=${COREOS_PRIVATE_IPV4}" \
-e "COREOS_PUBLIC_IPV4=${COREOS_PUBLIC_IPV4}" \
-e "POSTGRES_HOSTNAME=%H" \
-e "POSTGRES_PASSWORD=" \
-e "POSTGRES_USERNAME=postgres" \
-e "POSTGRES_PORT=5432" \
-e "POSTGRES_DATABASE=vis" \
quay.io/mojvis/vis-postgres-discovery
# Stop
ExecStop=/usr/bin/docker stop postgres-discovery-vis.1
[X-Fleet]
MachineOf=postgres.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment