Skip to content

Instantly share code, notes, and snippets.

@jwreagor
Last active November 10, 2017 03:48
Show Gist options
  • Save jwreagor/fb5a81ff590e898c5561d1851c827d9e to your computer and use it in GitHub Desktop.
Save jwreagor/fb5a81ff590e898c5561d1851c827d9e to your computer and use it in GitHub Desktop.
Example of how ContainerPilot handles jobs that continue running past their interval setting
{
consul: "consul:8500",
logging: {
level: "DEBUG",
format: "text"
},
jobs: [
{
name: "test-repeats",
exec: "/usr/local/bin/test-sleep.sh",
when: {
interval: "10s",
},
}
],
control: {
socket: "/tmp/cp-single.socket"
}
}
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 \
&& curl -Lso /tmp/containerpilot.tar.gz \
"https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VER}/containerpilot-${CONTAINERPILOT_VER}.tar.gz" \
&& echo "${CONTAINERPILOT_CHECKSUM} /tmp/containerpilot.tar.gz" | sha1sum -c \
&& tar zxf /tmp/containerpilot.tar.gz -C /bin \
&& rm /tmp/containerpilot.tar.gz
# COPY ContainerPilot configuration
COPY containerpilot.json5 /etc/containerpilot.json5
# Install our application
COPY test-sleep.sh /usr/local/bin
EXPOSE 3001
CMD ["/bin/containerpilot"]
#!/usr/bin/env bash
SLEEPY_TIME=$[ ( $RANDOM % 30 ) + 1 ]s
echo "Going to sleep for $SLEEPY_TIME"
date -R
sleep $SLEEPY_TIME
date -R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment