Commit 2b9d48cc authored by Jacob Vosmaer's avatar Jacob Vosmaer

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.
parent 21e3d848
...@@ -64,19 +64,19 @@ before_fork do |server, worker| ...@@ -64,19 +64,19 @@ before_fork do |server, worker|
# installations. It is not needed if your system can house # installations. It is not needed if your system can house
# twice as many worker_processes as you have configured. # twice as many worker_processes as you have configured.
# #
# # This allows a new master process to incrementally # This allows a new master process to incrementally
# # phase out the old master process with SIGTTOU to avoid a # phase out the old master process with SIGTTOU to avoid a
# # thundering herd (especially in the "preload_app false" case) # thundering herd (especially in the "preload_app false" case)
# # when doing a transparent upgrade. The last worker spawned # when doing a transparent upgrade. The last worker spawned
# # will then kill off the old master process with a SIGQUIT. # will then kill off the old master process with a SIGQUIT.
# old_pid = "#{server.config[:pid]}.oldbin" old_pid = "#{server.config[:pid]}.oldbin"
# if old_pid != server.pid if old_pid != server.pid
# begin begin
# sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
# Process.kill(sig, File.read(old_pid).to_i) Process.kill(sig, File.read(old_pid).to_i)
# rescue Errno::ENOENT, Errno::ESRCH rescue Errno::ENOENT, Errno::ESRCH
# end end
# end end
# #
# Throttle the master from forking too quickly by sleeping. Due # Throttle the master from forking too quickly by sleeping. Due
# to the implementation of standard Unix signal handlers, this # to the implementation of standard Unix signal handlers, this
......
...@@ -81,7 +81,7 @@ restart() { ...@@ -81,7 +81,7 @@ restart() {
if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then
echo "Restarting $DESC..." echo "Restarting $DESC..."
kill -USR2 `cat $WEB_SERVER_PID` kill -USR2 `cat $WEB_SERVER_PID`
execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1 &" execute "mkdir -p $PID_PATH && $STOP_SIDEKIQ > /dev/null 2>&1"
if [ `whoami` = root ]; then if [ `whoami` = root ]; then
execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &" execute "mkdir -p $PID_PATH && $START_SIDEKIQ > /dev/null 2>&1 &"
fi fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment