Commit dd7efd1768f7f61dfa8c47200fc95bac831c9ff5
1 parent
c0090a3f
Exists in
spb-stable
and in
3 other branches
Add load_ok check to script/background_jobs
Showing
1 changed file
with
24 additions
and
0 deletions
Show diff stats
script/background_jobs
... | ... | @@ -6,6 +6,11 @@ sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid" |
6 | 6 | sidekiq_logfile="$app_root/log/sidekiq.log" |
7 | 7 | gitlab_user=$(ls -l config.ru | awk '{print $3}') |
8 | 8 | |
9 | +function warn | |
10 | +{ | |
11 | + echo "$@" 1>&2 | |
12 | +} | |
13 | + | |
9 | 14 | function stop |
10 | 15 | { |
11 | 16 | bundle exec sidekiqctl stop $sidekiq_pidfile >> $sidekiq_logfile 2>&1 |
... | ... | @@ -35,6 +40,22 @@ function start_sidekiq |
35 | 40 | bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e $RAILS_ENV -P $sidekiq_pidfile $@ >> $sidekiq_logfile 2>&1 |
36 | 41 | } |
37 | 42 | |
43 | +function load_ok | |
44 | +{ | |
45 | + sidekiq_pid=$(cat $sidekiq_pidfile) | |
46 | + if [[ -z $sidekiq_pid ]] ; then | |
47 | + warn "Could not find a PID in $sidekiq_pidfile" | |
48 | + exit 0 | |
49 | + fi | |
50 | + | |
51 | + if (ps -p $sidekiq_pid -o args | grep '\([0-9]\+\) of \1 busy' 1>&2) ; then | |
52 | + warn "Too many busy Sidekiq workers" | |
53 | + exit 1 | |
54 | + fi | |
55 | + | |
56 | + exit 0 | |
57 | +} | |
58 | + | |
38 | 59 | case "$1" in |
39 | 60 | stop) |
40 | 61 | stop |
... | ... | @@ -51,6 +72,9 @@ case "$1" in |
51 | 72 | killall) |
52 | 73 | killall |
53 | 74 | ;; |
75 | + load_ok) | |
76 | + load_ok | |
77 | + ;; | |
54 | 78 | *) |
55 | 79 | echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall}" |
56 | 80 | esac | ... | ... |