@@ -85,7 +85,7 @@ check_pids(){
85
85
wait_for_pids (){
86
86
# We are sleeping a bit here mostly because sidekiq is slow at writing it's pid
87
87
i=0;
88
- while [ ! -f $web_server_pid_path -o ! -f $sidekiq_pid_path -o [ " $mail_room_enabled " = true && ! -f $mail_room_pid_path ] ] ; do
88
+ while [ ! -f $web_server_pid_path ] || [ ! -f $sidekiq_pid_path ] || { [ " $mail_room_enabled " = true ] && [ ! -f $mail_room_pid_path ] } ; do
89
89
sleep 0.1;
90
90
i=$(( i+ 1 ))
91
91
if [ $(( i% 10 )) = 0 ]; then
@@ -120,13 +120,15 @@ check_status(){
120
120
else
121
121
sidekiq_status=" -1"
122
122
fi
123
- if [ " $mail_room_enabled " = true && $mpid -ne 0 ]; then
124
- kill -0 " $mpid " 2> /dev/null
125
- mail_room_status=" $? "
126
- else
127
- mail_room_status=" -1"
123
+ if [ " $mail_room_enabled " = true ]; then
124
+ if [ $mpid -ne 0 ]; then
125
+ kill -0 " $mpid " 2> /dev/null
126
+ mail_room_status=" $? "
127
+ else
128
+ mail_room_status=" -1"
129
+ fi
128
130
fi
129
- if [ $web_status = 0 -a $sidekiq_status = 0 -a [ " $mail_room_enabled " != true || $mail_room_status = 0 ] ] ; then
131
+ if [ $web_status = 0 ] && [ $sidekiq_status = 0 ] && { [ " $mail_room_enabled " != true ] || [ $mail_room_status = 0 ] } ; then
130
132
gitlab_status=0
131
133
else
132
134
# http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
@@ -140,21 +142,21 @@ check_stale_pids(){
140
142
check_status
141
143
# If there is a pid it is something else than 0, the service is running if
142
144
# *_status is == 0.
143
- if [ " $wpid " != " 0" -a " $web_status " != " 0" ]; then
145
+ if [ " $wpid " != " 0" ] && [ " $web_status " != " 0" ]; then
144
146
echo " Removing stale Unicorn web server pid. This is most likely caused by the web server crashing the last time it ran."
145
147
if ! rm " $web_server_pid_path " ; then
146
148
echo " Unable to remove stale pid, exiting."
147
149
exit 1
148
150
fi
149
151
fi
150
- if [ " $spid " != " 0" -a " $sidekiq_status " != " 0" ]; then
152
+ if [ " $spid " != " 0" ] && [ " $sidekiq_status " != " 0" ]; then
151
153
echo " Removing stale Sidekiq job dispatcher pid. This is most likely caused by Sidekiq crashing the last time it ran."
152
154
if ! rm " $sidekiq_pid_path " ; then
153
155
echo " Unable to remove stale pid, exiting"
154
156
exit 1
155
157
fi
156
158
fi
157
- if [ " $mail_room_enabled " = true && " $mpid " != " 0" -a " $mail_room_status " != " 0" ]; then
159
+ if [ " $mail_room_enabled " = true ] && [ " $mpid " != " 0" ] && [ " $mail_room_status " != " 0" ]; then
158
160
echo " Removing stale MailRoom job dispatcher pid. This is most likely caused by MailRoom crashing the last time it ran."
159
161
if ! rm " $mail_room_pid_path " ; then
160
162
echo " Unable to remove stale pid, exiting"
@@ -166,7 +168,7 @@ check_stale_pids(){
166
168
# # If no parts of the service is running, bail out.
167
169
exit_if_not_running (){
168
170
check_stale_pids
169
- if [ " $web_status " != " 0" -a " $sidekiq_status " != " 0" -a [ " $mail_room_enabled " = true && " $mail_room_status " != " 0" ] ] ; then
171
+ if [ " $web_status " != " 0" ] && [ " $sidekiq_status " != " 0" ] && { [ " $mail_room_enabled " ! = true ] || [ " $mail_room_status " != " 0" ] } ; then
170
172
echo " GitLab is not running."
171
173
exit
172
174
fi
@@ -182,7 +184,7 @@ start_gitlab() {
182
184
if [ " $sidekiq_status " != " 0" ]; then
183
185
echo -n " Starting GitLab Sidekiq"
184
186
fi
185
- if [ " $mail_room_enabled " = true && " $mail_room_status " != " 0" ]; then
187
+ if [ " $mail_room_enabled " = true ] && [ " $mail_room_status " != " 0" ]; then
186
188
echo -n " Starting GitLab MailRoom"
187
189
fi
188
190
@@ -206,7 +208,7 @@ start_gitlab() {
206
208
if [ " $mail_room_enabled " = true ]; then
207
209
# If MailRoom is already running, don't start it again.
208
210
if [ " $mail_room_status " = " 0" ]; then
209
- echo " The MailRoom email processor is already running with pid $spid , not restarting"
211
+ echo " The MailRoom email processor is already running with pid $mpid , not restarting"
210
212
else
211
213
RAILS_ENV=$RAILS_ENV bin/mail_room start &
212
214
fi
@@ -228,7 +230,7 @@ stop_gitlab() {
228
230
if [ " $sidekiq_status " = " 0" ]; then
229
231
echo -n " Shutting down GitLab Sidekiq"
230
232
fi
231
- if [ " $mail_room_enabled " = true && " $mail_room_status " = " 0" ]; then
233
+ if [ " $mail_room_enabled " = true ] && [ " $mail_room_status " = " 0" ]; then
232
234
echo -n " Shutting down GitLab MailRoom"
233
235
fi
234
236
@@ -241,16 +243,16 @@ stop_gitlab() {
241
243
RAILS_ENV=$RAILS_ENV bin/background_jobs stop
242
244
fi
243
245
# And do the same thing for the MailRoom.
244
- if [ " $mail_room_enabled " = true && " $mail_room_status " = " 0" ]; then
246
+ if [ " $mail_room_enabled " = true ] && [ " $mail_room_status " = " 0" ]; then
245
247
RAILS_ENV=$RAILS_ENV bin/mail_room stop
246
248
fi
247
249
248
250
# If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script.
249
- while [ " $web_status " = " 0" -o " $sidekiq_status " = " 0" -o [ " $mail_room_enabled " = true && " $mail_room_status " = " 0" ] ] ; do
251
+ while [ " $web_status " = " 0" ] || [ " $sidekiq_status " = " 0" ] || { [ " $mail_room_enabled " = true ] && [ " $mail_room_status " = " 0" ] } ; do
250
252
sleep 1
251
253
check_status
252
254
printf " ."
253
- if [ " $web_status " != " 0" -a " $sidekiq_status " != " 0" -a [ " $mail_room_enabled " != true || " $mail_room_status " != " 0" ] ] ; then
255
+ if [ " $web_status " != " 0" ] && [ " $sidekiq_status " != " 0" ] && { [ " $mail_room_enabled " != true ] || [ " $mail_room_status " != " 0" ] } ; then
254
256
printf " \n"
255
257
break
256
258
fi
@@ -270,7 +272,7 @@ stop_gitlab() {
270
272
# # Prints the status of GitLab and it's components.
271
273
print_status () {
272
274
check_status
273
- if [ " $web_status " != " 0" -a " $sidekiq_status " != " 0" -a [ " $mail_room_enabled " != true || " $mail_room_status " != " 0" ] ] ; then
275
+ if [ " $web_status " != " 0" ] && [ " $sidekiq_status " != " 0" ] && { [ " $mail_room_enabled " != true ] || [ " $mail_room_status " != " 0" ] } ; then
274
276
echo " GitLab is not running."
275
277
return
276
278
fi
@@ -291,7 +293,7 @@ print_status() {
291
293
printf " The GitLab MailRoom email processor is \033[31mnot running\033[0m.\n"
292
294
fi
293
295
end
294
- if [ " $web_status " = " 0" -a " $sidekiq_status " = " 0" -a [ " $mail_room_enabled " != true || " $mail_room_status " = " 0" ] ] ; then
296
+ if [ " $web_status " = " 0" ] && [ " $sidekiq_status " = " 0" ] && { [ " $mail_room_enabled " != true ] || [ " $mail_room_status " = " 0" ] } ; then
295
297
printf " GitLab and all its components are \033[32mup and running\033[0m.\n"
296
298
fi
297
299
}
@@ -322,7 +324,7 @@ reload_gitlab(){
322
324
# # Restarts Sidekiq and Unicorn.
323
325
restart_gitlab (){
324
326
check_status
325
- if [ " $web_status " = " 0" -o " $sidekiq_status " = " 0" -o [ " $mail_room_enabled " = true && " $mail_room_status " = " 0" ] ] ; then
327
+ if [ " $web_status " = " 0" ] || [ " $sidekiq_status " = " 0" ] || { [ " $mail_room_enabled " = true ] && [ " $mail_room_status " = " 0" ] } ; then
326
328
stop_gitlab
327
329
fi
328
330
start_gitlab
0 commit comments