Skip to content

Updated most files for Docker Cloud migration #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM sillelien/base-alpine:0.9.2
FROM sillelien/base-alpine:0.10

RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk update && apk upgrade && \
Expand All @@ -9,4 +9,3 @@ RUN chmod 755 /run.sh
COPY cron.sh /etc/services.d/cron/run
RUN chmod 755 /etc/services.d/cron/run
CMD /run.sh

24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# A Cron Scheduler for Tutum

##Intro
## Intro

To use you simply need to add a link to each service you wish to schedule and then an environment variable that starts with the capitalized name of the service and which ends in _CRON_SCHEDULE, e.g.:

Expand All @@ -21,30 +21,32 @@ You'll also want to make sure you add the `global` role on tutum-cron:

Everything you really need to know is in the `tutum.yml` file, just take a look and you'll get the idea. So just press the button and get going:

[![Deploy to Tutum](https://s.tutum.co/deploy-to-tutum.svg)](https://dashboard.tutum.co/stack/deploy/)
[![Deploy to Docker Cloud](https://files.cloud.docker.com/images/deploy-to-dockercloud.svg)


## Schedules


##Schedules

Everything you need to know about scheduling can be found in the [fcrontab documentation](http://fcron.free.fr/doc/en/fcrontab.5.html) but simply you can use the cron syntax you are familiar with:

<pre><b>* * * * * *</b>
| | | | | |
```
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)</pre>
+------------ Minute (range: 0-59)
```

You can of course use an online generator such as http://crontab-generator.org/ to help you along.

##Further Info
## Further Info

This scheduler uses [fcron](http://fcron.free.fr/doc/en/fcrontab.5.html) to schedule commands, fcron is great because like anacron it catches up with running services it misses while down. So it's totally okay to change the config and restart the server.
This scheduler uses [fcron](http://fcron.free.fr/doc/en/fcrontab.5.html) to schedule commands, fcron is great because like anacron it catches up with running services it misses while down. So it's totally okay to change the config and restart the server.

The base container uses work originally taken from https://github.com/just-containers/base-alpine credit to <John Regan>john@jrjrtech.com this provides us with the S6 supervisor which this image uses to run cron, dnsmasq and the main run.sh script.

The real base of this image though is [Alpine Linux](https://www.alpinelinux.org/) brought to Docker via [Glider Labs](http://gliderlabs.com/).

[![](https://badge.imagelayers.io/vizzbuzz/tutum-cron.svg)](https://imagelayers.io/?images=vizzbuzz/tutum-cron:latest 'Get your own badge on imagelayers.io')
13 changes: 7 additions & 6 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ done

while true
do
env_vars=$(env | grep ".*_TUTUM_API_URL=" | cut -d= -f1 | tr '\n' ' ')
env_vars=$(env | grep ".*_DOCKERCLOUD_SERVICE_API_URL=" | cut -d= -f1 | tr '\n' ' ')

[ ! -f /tmp/cron.tmp ] || rm /tmp/cron.tmp

for env_var in $env_vars
do
# Set on the remote service
schedule_env_var=${env_var%_TUTUM_API_URL}_ENV_CRON_SCHEDULE
schedule_env_var=${env_var%_ENV_DOCKERCLOUD_SERVICE_API_URL}_ENV_CRON_SCHEDULE
# Set on the cron service
schedule_var=${env_var%_TUTUM_API_URL}_CRON_SCHEDULE
schedule_var=${env_var%_ENV_DOCKERCLOUD_SERVICE_API_URL}_CRON_SCHEDULE

if [[ -n $schedule_var ]]
then
Expand All @@ -27,9 +27,12 @@ do
fi
service_url=${!env_var}

if [[ -n $schedule ]]
then
cat <<EOF >> /tmp/cron.tmp
${schedule} curl -X POST -H "Authorization: $TUTUM_AUTH" -H "Accept: application/json" ${service_url}start/
${schedule} curl -X POST -H "Authorization: $DOCKERCLOUD_AUTH" -H "Accept: application/json" ${service_url}start/
EOF
fi
done

echo "Installing new crontab"
Expand All @@ -38,5 +41,3 @@ EOF
fcrontab /tmp/cron.tmp
sleep 86400
done


5 changes: 2 additions & 3 deletions tutum.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tutum-cron:
image: vizzbuzz/tutum-cron
cloud-cron:
image: sillelien/tutum-cron
autorestart: always
cpu_shares: 128
mem_limit: 64m
Expand All @@ -14,4 +14,3 @@ tutum-cron:
test:
image: alpine
command: 'echo On Schedule'