Commit cda4d6881aba6ebcdd71a8f1c47976e77cf9e9aa

Authored by Rovanion
Committed by GitLab
1 parent f57944cc

Fixed failure to stop and added handling of failure to remove stale pid

Showing 1 changed file with 17 additions and 7 deletions   Show diff stats
lib/support/init.d/gitlab
@@ -20,8 +20,8 @@ RAILS_ENV="production" @@ -20,8 +20,8 @@ RAILS_ENV="production"
20 20
21 # Script variable names should be lower-case not to conflict with internal 21 # Script variable names should be lower-case not to conflict with internal
22 # /bin/sh variables such as PATH, EDITOR or SHELL. 22 # /bin/sh variables such as PATH, EDITOR or SHELL.
23 -app_root="/home/gitlab/gitlab"  
24 -app_user="gitlab" 23 +app_root="/home/git/gitlab"
  24 +app_user="git"
25 unicorn_conf="$app_root/config/unicorn.rb" 25 unicorn_conf="$app_root/config/unicorn.rb"
26 pid_path="$app_root/tmp/pids" 26 pid_path="$app_root/tmp/pids"
27 socket_path="$app_root/tmp/sockets" 27 socket_path="$app_root/tmp/sockets"
@@ -76,10 +76,14 @@ check_status(){ @@ -76,10 +76,14 @@ check_status(){
76 if [ $wpid -ne 0 ]; then 76 if [ $wpid -ne 0 ]; then
77 kill -0 "$wpid" 2>/dev/null 77 kill -0 "$wpid" 2>/dev/null
78 web_status="$?" 78 web_status="$?"
  79 + else
  80 + web_status="-1"
79 fi 81 fi
80 if [ $spid -ne 0 ]; then 82 if [ $spid -ne 0 ]; then
81 kill -0 "$spid" 2>/dev/null 83 kill -0 "$spid" 2>/dev/null
82 sidekiq_status="$?" 84 sidekiq_status="$?"
  85 + else
  86 + sidekiq_status="-1"
83 fi 87 fi
84 } 88 }
85 89
@@ -89,12 +93,18 @@ check_stale_pids(){ @@ -89,12 +93,18 @@ check_stale_pids(){
89 # If there is a pid it is something else than 0, the service is running if 93 # If there is a pid it is something else than 0, the service is running if
90 # *_status is == 0. 94 # *_status is == 0.
91 if [ "$wpid" != "0" -a "$web_status" != "0" ]; then 95 if [ "$wpid" != "0" -a "$web_status" != "0" ]; then
92 - echo "Found stale Unicorn web server pid, removing. This is most likely caused by the web server crashing the last time it ran."  
93 - rm "$web_server_pid_path" 96 + echo "Removing stale Unicorn web server pid. This is most likely caused by the web server crashing the last time it ran."
  97 + if ! rm "$web_server_pid_path"; then
  98 + echo "Unable to remove stale pid, exiting"
  99 + exit 1
  100 + fi
94 fi 101 fi
95 if [ "$spid" != "0" -a "$sidekiq_status" != "0" ]; then 102 if [ "$spid" != "0" -a "$sidekiq_status" != "0" ]; then
96 - echo "Found stale Sidekiq web server pid, removing. This is most likely caused by the Sidekiq crashing the last time it ran."  
97 - rm "$sidekiq_pid_path" 103 + echo "Removing stale Sidekiq web server pid. This is most likely caused by the Sidekiq crashing the last time it ran."
  104 + if ! rm "$sidekiq_pid_path"; then
  105 + echo "Unable to remove stale pid, exiting"
  106 + exit 1
  107 + fi
98 fi 108 fi
99 } 109 }
100 110
@@ -205,7 +215,7 @@ reload(){ @@ -205,7 +215,7 @@ reload(){
205 echo "Done." 215 echo "Done."
206 echo "Restarting GitLab Sidekiq since it isn't capable of reloading it's config..." 216 echo "Restarting GitLab Sidekiq since it isn't capable of reloading it's config..."
207 RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:stop 217 RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:stop
208 - echo "Starting Sidekiq..." 218 + echo "Starting Sidekiq..."
209 RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:start 219 RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:start
210 # Waiting 2 seconds for sidekiq to write it. 220 # Waiting 2 seconds for sidekiq to write it.
211 sleep 2 221 sleep 2