-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathunit.go
More file actions
39 lines (30 loc) · 927 Bytes
/
unit.go
File metadata and controls
39 lines (30 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
//TODO - expand template to process a list of dependencies
type Unit struct {
Service string
Dependency string
AppName string
}
const UnitTemplate =
`
[Unit]
Description=Service unit for docker service [[.Service]]
After=[[.Dependency]].service
BindsTo=[[.Dependency]].service
Conflicts=shutdown.target reboot.target halt.target
[Service]
Environment=APP='[[.Service]]'
TimeoutStartSec=0
TimeoutStopSec=30
Restart=always
RestartSec=10
WorkingDirectory=/opt/dockerapps/[[.AppName]]
ExecStartPre=-/usr/local/bin/docker-compose kill $APP
ExecStartPre=-/usr/local/bin/docker-compose rm $APP
ExecStartPre=-/usr/local/bin/docker-compose rm -f $APP
ExecStart=/usr/bin/envconsul -consul={{consul_addr}} -once -prefix=dc/{{env_prefix}} env /usr/local/bin/docker-compose up --force-recreate --no-deps $APP
ExecStop=/usr/local/bin/docker-compose stop $APP
NotifyAccess=all
[Install]
WantedBy=multi-user.target
`