-
CONSUL
is the address of our Consul cluster. This defaults to just"consul"
if used by local Docker linked containers. -
Only if the env var
CONSUL_AGENT
is available do we want to run theconsul-agent
job. This runs theconsul
agent process inside our container which ourcontainerpilot
process will use to communicate with our external Consul cluster. We also wantconsul-agent
to have ahealth
check as well. -
Run the
preStart
job. This can be used to preconfigure the "main" service of a container like setting an IP address inside a configuration file. -
Caveat: If we're given
CONSUL_AGENT
than ourpreStart
will run after theconsul-agent
job ishealthy
.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEBU[0000] loaded config: {"Discovery":{},"LogConfig":{"level":"DEBUG","format":"text","output":"stdout"},"StopTimeout":5,"Jobs":[{"Name":"test-repeats","Exec":"./test-sleep.sh","Port":0,"Interfaces":null,"Tags":null,"ConsulExtras":null,"Health":null,"ExecTimeout":"never","Restarts":null,"StopTimeout":"","When":{"Frequency":"12s","Source":"","Once":"","Each":"","Timeout":""},"Logging":null}],"Watches":null,"Telemetry":null,"Control":{"SocketPath":"/tmp/cp-single.socket"}} | |
DEBU[0000] control: initialized router for control server | |
DEBU[0000] control: listening to /tmp/cp-single.socket | |
DEBU[0000] event: {Startup global} | |
DEBU[0000] test-repeats.Run start | |
INFO[0000] control: serving at /tmp/cp-single.socket | |
INFO[0000] Going to sleep for 10s job=test-repeats pid=26574 | |
INFO[0000] Tue, 21 Nov 2017 11:30:48 -0500 job=test-repeats pid=26574 | |
INFO[0010] Tue, 21 Nov 2017 11:30:58 -0500 job=test-repeats pid=26574 | |
DEBU[0010] test-repeats exited without error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== RUN TestFoo_bar | |
bootstrap = true: do not enable unless necessary | |
==> Starting Consul agent... | |
==> Consul agent running! | |
Version: 'v1.0.0' | |
Node ID: 'd4afaaf6-c5fb-ac84-746f-9971f07e465d' | |
Node name: 'node-d4afaaf6-c5fb-ac84-746f-9971f07e465d' | |
Datacenter: 'dc1' (Segment: '<all>') | |
Server: true (Bootstrap: true) | |
Client Addr: [127.0.0.1] (HTTP: 10002, HTTPS: 10003, DNS: 10001) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:latest | |
RUN apk update && \ | |
apk add curl bash | |
# Install ContainerPilot | |
ENV CONTAINERPILOT_VER=3.5.1 | |
ENV CONTAINERPILOT=/etc/containerpilot.json5 | |
RUN export CONTAINERPILOT_CHECKSUM=7ee8e59588b6b593325930b0dc18d01f666031d7 \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
consul: "consul:8500", | |
logging: { | |
level: "DEBUG", | |
format: "text" | |
}, | |
jobs: [ | |
{ | |
name: "test-thing", | |
exec: "tail -f" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*[f-signal-event][tzu][containerpilot]$ docker logs -f cpnew | |
time="2017-10-18T04:16:17Z" level=debug msg="loaded config: {"Discovery":{},"LogConfig":{"level":"DEBUG","format":"text","output":"stdout"},"StopTimeout":5,"Jobs":[{"Name":"on-sighup","Exec":"echo 'on-sighup job fired on SIGHUP'","Port":0,"Interfaces":null,"Tags":null,"ConsulExtras":null,"Health":null,"ExecTimeout":"","Restarts":null,"StopTimeout":"","When":{"Frequency":"","Source":"SIGHUP","Once":"","Each":"","Timeout":""},"Logging":null},{"Name":"on-sigusr2","Exec":"echo 'on-sigusr2 job fired on SIGUSR2'","Port":0,"Interfaces":null,"Tags":null,"ConsulExtras":null,"Health":null,"ExecTimeout":"","Restarts":null,"StopTimeout":"","When":{"Frequency":"","Source":"SIGUSR2","Once":"","Each":"","Timeout":""},"Logging":null}],"Watches":null,"Telemetry":null,"Control":{"SocketPath":"/var/run/containerpilot.socket"}}" | |
time="2017-10-18T04:16:17Z" level=debug msg="control: initialized router for control server" | |
time="2017-10-18T04:16:17Z" level=debug msg="cont |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
consul: "consul:8500", | |
logging: { level: "INFO" }, | |
jobs: [ | |
{ | |
name: "job1", | |
exec: "tail -F" | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
consul: "consul:8500", | |
jobs: [ | |
{ | |
name: "pjob", | |
port: 8080, | |
exec: "/bin/pjob start", | |
restarts: "unlimited", | |
health: { | |
exec: "curl --fail -s http://127.0.0.1:8080", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if opts.LogFile != "" { | |
logFp, err := os.OpenFile(opts.LogFile, os.O_WRONLY | os.O_APPEND | os.O_CREATE, 0600) | |
checkError(fmt.Sprintf("error opening %s", opts.LogFile), err) | |
defer logFp.Close() | |
// ensure panic output goes to log file | |
syscall.Dup2(int(logFp.Fd()), 1) | |
syscall.Dup2(int(logFp.Fd()), 2) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create backup user/policies (usage: make manta [email protected] PASSWORD=pwd) | |
# ------------------------------------------------------- | |
# Create user and policies for backups | |
# Requires SDC_ACCOUNT to be set | |
# usage: | |
# make manta [email protected] PASSWORD=strongpassword | |
# | |
## Create backup user and policies | |
manta: | |
$(call check_var, EMAIL PASSWORD SDC_ACCOUNT, \ |