Commit 585963ae1f48474605aa7f991a63d3a9d16bb1d4

Authored by Victor Costa
1 parent 7e1172c4

Restart with zero downtime

Showing 2 changed files with 16 additions and 5 deletions   Show diff stats
etc/init.d/noosfero
... ... @@ -115,8 +115,11 @@ do_stop() {
115 115 }
116 116  
117 117 do_restart() {
118   - do_stop
119   - do_start
  118 + if running; then
  119 + main_script restart
  120 + else
  121 + do_start
  122 + fi
120 123 }
121 124  
122 125 running(){
... ...
script/production
... ... @@ -45,6 +45,16 @@ do_stop() {
45 45 stop_via_pid_file tmp/pids/delayed_job.pid tmp/pids/delayed_job.*.pid tmp/pids/feed-updater.*.pid
46 46 }
47 47  
  48 +do_restart() {
  49 + rake db:migrate SCHEMA=/dev/null
  50 + environments_loop stop ||
  51 + stop_via_pid_file tmp/pids/delayed_job.pid tmp/pids/delayed_job.*.pid tmp/pids/feed-updater.*.pid
  52 + environments_loop start
  53 +
  54 + clear_cache
  55 + ruby -S thin -C config/thin.yml restart --onebyone
  56 +}
  57 +
48 58 stop_via_pid_file() {
49 59 for pidfile in $@; do
50 60 if [ -e "$pidfile" ]; then
... ... @@ -84,9 +94,7 @@ case "$ACTION" in
84 94 ;;
85 95  
86 96 restart)
87   - do_stop
88   - sleep 1
89   - do_start
  97 + do_restart
90 98 ;;
91 99  
92 100 *)
... ...