forked from TritonDataCenter/containerpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx-upstreams.json5
78 lines (78 loc) · 2.31 KB
/
nginx-upstreams.json5
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
This example demonstrates how a user can watch external dependencies via
'watches' and have jobs respond to changes in those dependencies.
*/
{
consul: "localhost:8500", // ContainerPilot talks to the local agent
jobs: [
{
// this job has no 'port' configuration so it will not be
// advertised to the Consul server. note there's no 'when' field
// so this will start on the 'global startup' event by default.
name: "consul-agent",
exec: [
"consul", "agent", "-rejoin", "-retry-join", "{{ .CONSUL }}",
"-retry-max", "10", "-retry-interval", "10s"
],
restarts: "unlimited",
health: {
exec: "consul info | grep leader"
}
},
{
// this job is not advertised and has no health check. we'll never
// see a 'preStart healthy' event, just 'preStart exitSuccess'
name: "preStart",
exec: [
"consul-template", "-once", "-consul-addr", "localhost:8500",
"-template", "/etc/template.ctmpl:/etc/nginx/conf.d/site.conf"
],
when: {
source: "consul-agent",
once: "healthy"
}
},
{
name: "onChange-app",
exec: [
"consul-template", "-once", "-consul-addr", "localhost:8500",
"-template", "/etc/template.ctmpl:/etc/nginx/conf.d/site.conf"
],
when: {
// this event will be received whenever the watch for 'app'
// sees a change in Consul.
source: "watch.app",
each: "changed"
}
},
{
name: "nginx",
exec: "nginx",
port: 80,
restarts: "unlimited",
when: {
// 'app' won't start until the 'preStart' has succeeeded, but we
// give up after 120 seconds
source: "preStart",
once: "exitSuccess"
timeout: "120s"
},
health: {
exec: "/usr/bin/curl --fail -s -o /dev/null http://localhost:80/health",
interval: 5,
ttl: 10
timeout: "10s" // the health check can have its own timeout
}
}
],
watches: [
{
// this watch will fire the following events:
// - 'watch.app changed' when there's a change in Consul
// - 'watch.app healthy' when app changes to being healthy
// - 'watch.app unhealthy' when app changes to being unhealthy
name: "app",
interval: 5
}
]
}