[Git][noosfero/noosfero][master] 2 commits: Fixes whenever in production for a multitenancy setup

Antonio Terceiro gitlab at mg.gitlab.com
Tue Nov 10 18:52:16 BRST 2015


Antonio Terceiro pushed to branch master at Noosfero / noosfero


Commits:
348b6cb5 by Larissa Reis at 2015-11-10T16:47:58Z
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.

- - - - -
8c698880 by Antonio Terceiro at 2015-11-10T20:51:53Z
Merge branch 'whenever-multitenancy' into 'master'

Fixes whenever in production for a multitenancy setup

Each cronjob has to run for all production environments. Currently they are
only running for the environment named production so it doesn't work in a
multitenancy setup.

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.

See merge request !705
- - - - -


2 changed files:

- script/production
- + script/whenever


Changes:

=====================================
script/production
=====================================
--- 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
 }
 


=====================================
script/whenever
=====================================
--- /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



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/bf2cbbd3dc1867b9aecf86a721f19701191c9909...8c6988805ef1474bfd7dcd8f92524f9eaf971eb8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20151110/66360330/attachment.html>


More information about the Noosfero-dev mailing list