Commit ea3ea3a8ef012caf49d623392a647a468cd6989b
Committed by
Antonio Terceiro
1 parent
ea7f9220
Exists in
stable-spb-1.4
and in
9 other branches
Fixes whenever in production for a multitenancy setup
Each cronjob has to run for all environments. I use `whenever --update-crontab` to append jobs for each environment, using the environment name as a whenever identifier, and then I have to clean the crontab of each environment generated jobs using the same identifier. (cherry picked from commit 348b6cb5d48effc34b8aa24a15144db49ad78567)
Showing
2 changed files
with
26 additions
and
3 deletions
Show diff stats
script/production
... | ... | @@ -48,7 +48,6 @@ do_start() { |
48 | 48 | bundle exec rake db:migrate SCHEMA=/dev/null |
49 | 49 | clear_cache |
50 | 50 | environments_loop start |
51 | - bundle exec whenever --write-crontab --set 'environment=production' | |
52 | 51 | app_server_start |
53 | 52 | } |
54 | 53 | |
... | ... | @@ -63,8 +62,6 @@ do_stop() { |
63 | 62 | |
64 | 63 | environments_loop stop || |
65 | 64 | stop_via_pid_file tmp/pids/delayed_job.pid tmp/pids/delayed_job.*.pid tmp/pids/feed-updater.*.pid |
66 | - | |
67 | - bundle exec whenever --clear-crontab | |
68 | 65 | } |
69 | 66 | |
70 | 67 | do_restart() { |
... | ... | @@ -97,10 +94,12 @@ environments_loop() { |
97 | 94 | env=$(basename $environment | cut -d. -f1) |
98 | 95 | RAILS_ENV=$env bundle exec ./script/delayed_job -i $env "$action" |
99 | 96 | RAILS_ENV=$env bundle exec ./script/feed-updater "$action" -i $env |
97 | + ./script/whenever $action $env | |
100 | 98 | done |
101 | 99 | else |
102 | 100 | bundle exec ./script/delayed_job "$action" |
103 | 101 | bundle exec ./script/feed-updater "$action" |
102 | + ./script/whenever $action | |
104 | 103 | fi |
105 | 104 | } |
106 | 105 | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +#!/bin/sh | |
2 | + | |
3 | +ACTION="$1" | |
4 | +ENV="$2" | |
5 | +if [ -z "$ENV" ]; then | |
6 | + ENV='production' | |
7 | +fi | |
8 | + | |
9 | +do_start(){ | |
10 | + bundle exec whenever --update-crontab $ENV --set "environment=$ENV" | |
11 | +} | |
12 | + | |
13 | +do_stop(){ | |
14 | + bundle exec whenever --clear-crontab $ENV | |
15 | +} | |
16 | +case "$ACTION" in | |
17 | + start|stop) | |
18 | + do_$ACTION | |
19 | + ;; | |
20 | + *) | |
21 | + echo "usage: $0 start|stop [environment]" | |
22 | + exit 1 | |
23 | + ;; | |
24 | +esac | ... | ... |