Skip to content

Commit 5a58281

Browse files
author
Julien Neuhart
committed
fixing tests (again) + improving README
1 parent 1e058c8 commit 5a58281

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ To do this, you need to configure 3 variables:
143143
# configure the user that will run cron (defaults to root)
144144
CRON_USER=root
145145
# configure the schedule for the cron job (here: run every minute)
146-
CRON_SCHEDULE=* * * * *
146+
CRON_SCHEDULE=* * * * * * *
147147
# last but not least, configure the command
148148
CRON_COMMAND=yarn run stuff
149149
```
@@ -154,15 +154,15 @@ If you have more than one job to run, you can suffix your environment variable w
154154

155155
```bash
156156
CRON_USER_1=root
157-
CRON_SCHEDULE_1=* * * * *
157+
CRON_SCHEDULE_1=* * * * * * *
158158
CRON_COMMAND_1=yarn run stuff
159159

160160
CRON_USER_2=www-data
161-
CRON_SCHEDULE_2=0 3 * * *
161+
CRON_SCHEDULE_2=* * * * * * *
162162
CRON_COMMAND_2=yarn run other-stuff
163163
```
164164

165-
**Important**: The cron runner we use is "Supercronic" and not the orginial "cron" that has a number of issues with containers.
165+
**Important**: The cron runner we use is [Supercronic](https://github.com/aptible/supercronic) and not the orginial "cron" that has a number of issues with containers.
166166
Even with Supercronic, the architecture of cron was never designed with Docker in mind (Cron is way older than Docker). It will run correctly on
167167
your container. If at some point you want to scale and add more containers, it will run on all your containers.
168168
At that point, if you only want to run a Cron task once for your application (and not once per container), you might

build-and-test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ RESULT=`docker run --rm -v $(pwd)/user1999:$CONTAINER_CWD thecodingmachine/nodej
1919
sudo rm -rf user1999
2020

2121
# Let's check that the crons are actually sending logs in the right place
22-
RESULT=`docker run --rm -e CRON_SCHEDULE_1="* * * * * * *" -e CRON_COMMAND_1="(>&1 echo "foobar")" thecodingmachine/nodejs:${BRANCH}-${VARIANT} -f Dockerfile.${VARIANT} sleep 1 2>&1 | grep -oP 'msg=foobar' | head -n1`
22+
RESULT=`docker run --rm -e CRON_SCHEDULE_1="* * * * * * *" -e CRON_COMMAND_1="(>&1 echo "foobar")" thecodingmachine/nodejs:${BRANCH}-${VARIANT} sleep 1 2>&1 | grep -oP 'msg=foobar' | head -n1`
2323
[[ "$RESULT" = "msg=foobar" ]]
2424

25-
RESULT=`docker run --rm -e CRON_SCHEDULE_1="* * * * * * *" -e CRON_COMMAND_1="(>&2 echo "error")" thecodingmachine/nodejs:${BRANCH}-${VARIANT} -f Dockerfile.${VARIANT} sleep 1 2>&1 | grep -oP 'msg=error' | head -n1`
25+
RESULT=`docker run --rm -e CRON_SCHEDULE_1="* * * * * * *" -e CRON_COMMAND_1="(>&2 echo "error")" thecodingmachine/nodejs:${BRANCH}-${VARIANT} sleep 1 2>&1 | grep -oP 'msg=error' | head -n1`
2626
[[ "$RESULT" = "msg=error" ]]
2727

2828
# Let's check that the cron with a user different from root is actually run.
29-
RESULT=`docker run --rm -e CRON_SCHEDULE_1="* * * * * * *" -e CRON_COMMAND_1="whoami" -e CRON_USER_1="docker" thecodingmachine/nodejs:${BRANCH}-${VARIANT} -f Dockerfile.${VARIANT} sleep 1 2>&1 | grep -oP 'msg=docker' | head -n1`
29+
RESULT=`docker run --rm -e CRON_SCHEDULE_1="* * * * * * *" -e CRON_COMMAND_1="whoami" -e CRON_USER_1="docker" thecodingmachine/nodejs:${BRANCH}-${VARIANT} sleep 1 2>&1 | grep -oP 'msg=docker' | head -n1`
3030
[[ "$RESULT" = "msg=docker" ]]
3131

3232
echo "Tests passed with success"

utils/docker-entrypoint-as-root.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ if [[ "$IMAGE_VARIANT" == "apache" ]]; then
5151
node /usr/local/bin/enable_apache_mods.js | bash
5252
fi
5353

54-
# output on the logs can be done by writing on the "tini" PID. Useful for CRONTAB
55-
TINI_PID=`ps -e | grep tini | awk '{print $1;}'`
56-
node /usr/local/bin/generate_cron.js $TINI_PID > /tmp/generated_crontab
54+
node /usr/local/bin/generate_cron.js > /tmp/generated_crontab
5755
chmod 0644 /tmp/generated_crontab
5856

5957
# If generated_crontab is not empty, start supercronic

0 commit comments

Comments
 (0)