[Unit]
Description=%p-%i

# Requirements
Requires=docker.service
Requires=etcd.service
Requires=mysql@%i.service
Requires=%p-importer@%i.service
Requires=%p-discovery@%i.service
Requires=backup@%i.timer

# Dependency ordering
After=docker.service
After=mysql@%i.service
After=%p-importer@%i.service
Before=%p-discovery@%i.service

[Service]
Restart=always
ExecStartPre=-/usr/bin/docker kill %p-%i
ExecStartPre=-/usr/bin/docker rm %p-%i
ExecStart=/usr/bin/docker run \
  --name %p-%i \
  --link mysql-%i:db \
  -v /data/domains/%i/%p/known-content:/app/known-content \
  -v /data/domains/%i/%p/.htaccess:/app/.htaccess \
  --env-file /data/domains/%i/%p/.env \
  indiehosters/known
ExecReload=/usr/bin/docker restart %p-%i
ExecStop=/usr/bin/docker stop %p-%i

[Install]
WantedBy=multi-user.target
