From 585963ae1f48474605aa7f991a63d3a9d16bb1d4 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Thu, 30 Oct 2014 08:51:16 -0300 Subject: [PATCH] Restart with zero downtime --- etc/init.d/noosfero | 7 +++++-- script/production | 14 +++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/etc/init.d/noosfero b/etc/init.d/noosfero index c06aae9..c7bcece 100755 --- a/etc/init.d/noosfero +++ b/etc/init.d/noosfero @@ -115,8 +115,11 @@ do_stop() { } do_restart() { - do_stop - do_start + if running; then + main_script restart + else + do_start + fi } running(){ diff --git a/script/production b/script/production index 1a8fb61..6403f12 100755 --- a/script/production +++ b/script/production @@ -45,6 +45,16 @@ do_stop() { stop_via_pid_file tmp/pids/delayed_job.pid tmp/pids/delayed_job.*.pid tmp/pids/feed-updater.*.pid } +do_restart() { + rake db:migrate SCHEMA=/dev/null + environments_loop stop || + stop_via_pid_file tmp/pids/delayed_job.pid tmp/pids/delayed_job.*.pid tmp/pids/feed-updater.*.pid + environments_loop start + + clear_cache + ruby -S thin -C config/thin.yml restart --onebyone +} + stop_via_pid_file() { for pidfile in $@; do if [ -e "$pidfile" ]; then @@ -84,9 +94,7 @@ case "$ACTION" in ;; restart) - do_stop - sleep 1 - do_start + do_restart ;; *) -- libgit2 0.21.2