Skip to content

Instantly share code, notes, and snippets.

@jwreagor
Created October 18, 2017 03:55
Show Gist options
  • Save jwreagor/47898557e4948a0754ca8945ee772148 to your computer and use it in GitHub Desktop.
Save jwreagor/47898557e4948a0754ca8945ee772148 to your computer and use it in GitHub Desktop.
{
consul: "consul:8500",
logging: { level: "INFO" },
jobs: [
{
name: "job1",
exec: "tail -F"
}
]
}
{
consul: "consul:8500",
logging: { level: "INFO" },
jobs: [
{
name: "job1",
exec: "/minimal/write-logs.sh"
}
]
}
{
consul: "consul:8500",
logging: { level: "INFO" },
jobs: [
{
name: "job1",
exec: "tail -F",
health: {
exec: "true",
interval: 1,
ttl: 10
}
}
]
}
{
consul: "consul:8500",
logging: { level: "INFO" },
jobs: [
{
name: "job1",
exec: "tail -F",
port: 8000,
health: {
exec: "true",
interval: 1,
ttl: 10
}
}
]
}
#!/bin/bash
now=$(date +%s)
run-with-config() {
name=$1
docker run -d \
--name "$name" \
-v "$(pwd):/minimal" \
--link containerpilot_consul:consul \
leaky \
/minimal/containerpilot -config "/minimal/${name}.json5"
}
do-pmap() {
name=$1
pid=$(docker exec -it "$name" pgrep containerpilot | tail -1 | tr -d '[:space:]')
docker exec -it "$name" pmap -x "$pid" > "pmaps/${name}-$now"
}
do-profile() {
name=$1
docker exec -it "$name" \
curl -so "/minimal/profiles/heap-${name}-${now}" \
"http://localhost:6060/debug/pprof/heap?debug=1"
}
run() {
docker rm -f containerpilot_consul > /dev/null 2>&1 || true
docker run -d -m 256m -p 8500:8500 --name containerpilot_consul \
consul:latest agent -dev -client 0.0.0.0 -bind=0.0.0.0
# run-with-config do-nothing
run-with-config job-only
run-with-config job-that-logs
run-with-config job-with-health-check
run-with-config job-with-service
run-with-config watch-only
run-with-config watch-trigger-job
}
profiles() {
mkdir -p profiles
mkdir -p pmaps
while true; do
now=$(date +%s)
# do-profile do-nothing
do-profile job-only
do-profile job-that-logs
do-profile job-with-health-check
do-profile job-with-service
do-profile watch-only
do-profile watch-trigger-job
# do-pmap do-nothing
do-pmap job-only
do-pmap job-that-logs
do-pmap job-with-health-check
do-pmap job-with-service
do-pmap watch-only
do-pmap watch-trigger-job
sleep 300
done
}
cmd=$1
shift
$cmd "$@"
{
consul: "consul:8500",
logging: { level: "INFO" },
watches: [
{
name: "job1",
interval: 5
}
]
}
{
consul: "consul:8500",
logging: { level: "INFO" },
jobs: [
{
name: "job2",
exec: "true",
when: {
source: "watch.job1",
each: "changed"
}
}
],
watches: [
{
name: "job1",
interval: 5
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment