Commit 2b9d48ccd020a4ff62741118be94ab8d8f3b08b9
1 parent
21e3d848
Exists in
master
and in
4 other branches
Fix the `service gitlab restart` command
This commit addresses two related issues: - Sidekiq should shut down completely before we restart it; - If we restart unicorn with USR2 we need to kill the old master and worker processes.
Showing
2 changed files
with
14 additions
and
14 deletions
Show diff stats
config/unicorn.rb.example
@@ -64,19 +64,19 @@ before_fork do |server, worker| | @@ -64,19 +64,19 @@ before_fork do |server, worker| | ||
64 | # installations. It is not needed if your system can house | 64 | # installations. It is not needed if your system can house |
65 | # twice as many worker_processes as you have configured. | 65 | # twice as many worker_processes as you have configured. |
66 | # | 66 | # |
67 | - # # This allows a new master process to incrementally | ||
68 | - # # phase out the old master process with SIGTTOU to avoid a | ||
69 | - # # thundering herd (especially in the "preload_app false" case) | ||
70 | - # # when doing a transparent upgrade. The last worker spawned | ||
71 | - # # will then kill off the old master process with a SIGQUIT. | ||
72 | - # old_pid = "#{server.config[:pid]}.oldbin" | ||
73 | - # if old_pid != server.pid | ||
74 | - # begin | ||
75 | - # sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU | ||
76 | - # Process.kill(sig, File.read(old_pid).to_i) | ||
77 | - # rescue Errno::ENOENT, Errno::ESRCH | ||
78 | - # end | ||
79 | - # end | 67 | + # This allows a new master process to incrementally |
68 | + # phase out the old master process with SIGTTOU to avoid a | ||
69 | + # thundering herd (especially in the "preload_app false" case) | ||
70 | + # when doing a transparent upgrade. The last worker spawned | ||
71 | + # will then kill off the old master process with a SIGQUIT. | ||
72 | + old_pid = "#{server.config[:pid]}.oldbin" | ||
73 | + if old_pid != server.pid | ||
74 | + begin | ||
75 | + sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU | ||
76 | + Process.kill(sig, File.read(old_pid).to_i) | ||
77 | + rescue Errno::ENOENT, Errno::ESRCH | ||
78 | + end | ||
79 | + end | ||
80 | # | 80 | # |
81 | # Throttle the master from forking too quickly by sleeping. Due | 81 | # Throttle the master from forking too quickly by sleeping. Due |
82 | # to the implementation of standard Unix signal handlers, this | 82 | # to the implementation of standard Unix signal handlers, this |
lib/support/init.d/gitlab
@@ -81,7 +81,7 @@ restart() { | @@ -81,7 +81,7 @@ restart() { | ||
81 | if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | 81 | if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then |
82 | echo "Restarting $DESC..." | 82 | echo "Restarting $DESC..." |
83 | kill -USR2 `cat $WEB_SERVER_PID` | 83 | kill -USR2 `cat $WEB_SERVER_PID` |
84 | - execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" | 84 | + execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1" |
85 | if [ `whoami` = root ]; then | 85 | if [ `whoami` = root ]; then |
86 | execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" | 86 | execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" |
87 | fi | 87 | fi |