Skip to content

Instantly share code, notes, and snippets.

@kerin
Created April 22, 2015 10:00
Show Gist options
  • Save kerin/93f11e16ac06fabf675d to your computer and use it in GitHub Desktop.
Save kerin/93f11e16ac06fabf675d to your computer and use it in GitHub Desktop.
[Unit]
Description=VIS django service on port 8080
# Requirements
Requires=etcd.service
Requires=docker.service
Requires=django-discovery@%i.service
Requires=postgres-discovery.service
# Dependency ordering
After=etcd.service
After=docker.service
After=postgres-discovery.service
Before=django-discovery@%i.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 django.%i
ExecStartPre=-/usr/bin/docker rm django.%i
ExecStartPre=/usr/bin/docker pull quay.io/mojvis/vis
ExecStartPre=/usr/bin/docker run -t quay.io/mojvis/vis \
/bin/bash -c \
'/usr/local/bin/confd -onetime -backend etcd -node http://172.17.42.1:4001 \
&& /usr/bin/python manage.py migrate'
ExecStart=/usr/bin/docker run --name django.%i \
-e "COREOS_PRIVATE_IPV4=${COREOS_PRIVATE_IPV4}" \
-p ${COREOS_PUBLIC_IPV4}:8080:80 \
quay.io/mojvis/vis
# Stop
ExecStop=/usr/bin/docker stop django.%i
[X-Fleet]
# Don't schedule on the same machine as other Postgres instances
Conflicts=django@*.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment