diff --git a/script/production b/script/production index d41e01c..ce92a13 100755 --- a/script/production +++ b/script/production @@ -48,7 +48,6 @@ do_start() { bundle exec rake db:migrate SCHEMA=/dev/null clear_cache environments_loop start - bundle exec whenever --write-crontab --set 'environment=production' app_server_start } @@ -63,8 +62,6 @@ do_stop() { environments_loop stop || stop_via_pid_file tmp/pids/delayed_job.pid tmp/pids/delayed_job.*.pid tmp/pids/feed-updater.*.pid - - bundle exec whenever --clear-crontab } do_restart() { @@ -97,10 +94,12 @@ environments_loop() { env=$(basename $environment | cut -d. -f1) RAILS_ENV=$env bundle exec ./script/delayed_job -i $env "$action" RAILS_ENV=$env bundle exec ./script/feed-updater "$action" -i $env + ./script/whenever $action $env done else bundle exec ./script/delayed_job "$action" bundle exec ./script/feed-updater "$action" + ./script/whenever $action fi } diff --git a/script/whenever b/script/whenever new file mode 100755 index 0000000..75d8c10 --- /dev/null +++ b/script/whenever @@ -0,0 +1,24 @@ +#!/bin/sh + +ACTION="$1" +ENV="$2" +if [ -z "$ENV" ]; then + ENV='production' +fi + +do_start(){ + bundle exec whenever --update-crontab $ENV --set "environment=$ENV" +} + +do_stop(){ + bundle exec whenever --clear-crontab $ENV +} +case "$ACTION" in + start|stop) + do_$ACTION + ;; + *) + echo "usage: $0 start|stop [environment]" + exit 1 + ;; +esac -- libgit2 0.21.2