Commit cda4d6881aba6ebcdd71a8f1c47976e77cf9e9aa
Committed by
GitLab
1 parent
f57944cc
Exists in
master
and in
4 other branches
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 | 20 | |
| 21 | 21 | # Script variable names should be lower-case not to conflict with internal |
| 22 | 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 | 25 | unicorn_conf="$app_root/config/unicorn.rb" |
| 26 | 26 | pid_path="$app_root/tmp/pids" |
| 27 | 27 | socket_path="$app_root/tmp/sockets" |
| ... | ... | @@ -76,10 +76,14 @@ check_status(){ |
| 76 | 76 | if [ $wpid -ne 0 ]; then |
| 77 | 77 | kill -0 "$wpid" 2>/dev/null |
| 78 | 78 | web_status="$?" |
| 79 | + else | |
| 80 | + web_status="-1" | |
| 79 | 81 | fi |
| 80 | 82 | if [ $spid -ne 0 ]; then |
| 81 | 83 | kill -0 "$spid" 2>/dev/null |
| 82 | 84 | sidekiq_status="$?" |
| 85 | + else | |
| 86 | + sidekiq_status="-1" | |
| 83 | 87 | fi |
| 84 | 88 | } |
| 85 | 89 | |
| ... | ... | @@ -89,12 +93,18 @@ check_stale_pids(){ |
| 89 | 93 | # If there is a pid it is something else than 0, the service is running if |
| 90 | 94 | # *_status is == 0. |
| 91 | 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 | 101 | fi |
| 95 | 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 | 108 | fi |
| 99 | 109 | } |
| 100 | 110 | |
| ... | ... | @@ -205,7 +215,7 @@ reload(){ |
| 205 | 215 | echo "Done." |
| 206 | 216 | echo "Restarting GitLab Sidekiq since it isn't capable of reloading it's config..." |
| 207 | 217 | RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:stop |
| 208 | - echo "Starting Sidekiq..." | |
| 218 | + echo "Starting Sidekiq..." | |
| 209 | 219 | RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:start |
| 210 | 220 | # Waiting 2 seconds for sidekiq to write it. |
| 211 | 221 | sleep 2 | ... | ... |