Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1202875d
Commit
1202875d
authored
Aug 19, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix lib/support/init.d/gitlab.
parent
c50e5e68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
lib/support/init.d/gitlab
lib/support/init.d/gitlab
+22
-20
No files found.
lib/support/init.d/gitlab
View file @
1202875d
...
@@ -85,7 +85,7 @@ check_pids(){
...
@@ -85,7 +85,7 @@ check_pids(){
wait_for_pids
(){
wait_for_pids
(){
# We are sleeping a bit here mostly because sidekiq is slow at writing it's pid
# We are sleeping a bit here mostly because sidekiq is slow at writing it's pid
i
=
0
;
i
=
0
;
while
[
!
-f
$web_server_pid_path
-o
!
-f
$sidekiq_pid_path
-o
[
"
$mail_room_enabled
"
=
true
&&
!
-f
$mail_room_pid_path
]
]
;
do
while
[
!
-f
$web_server_pid_path
]
||
[
!
-f
$sidekiq_pid_path
]
||
{
[
"
$mail_room_enabled
"
=
true
]
&&
[
!
-f
$mail_room_pid_path
]
}
;
do
sleep
0.1
;
sleep
0.1
;
i
=
$((
i+1
))
i
=
$((
i+1
))
if
[
$((
i%10
))
=
0
]
;
then
if
[
$((
i%10
))
=
0
]
;
then
...
@@ -120,13 +120,15 @@ check_status(){
...
@@ -120,13 +120,15 @@ check_status(){
else
else
sidekiq_status
=
"-1"
sidekiq_status
=
"-1"
fi
fi
if
[
"
$mail_room_enabled
"
=
true
&&
$mpid
-ne
0
]
;
then
if
[
"
$mail_room_enabled
"
=
true
]
;
then
kill
-0
"
$mpid
"
2>/dev/null
if
[
$mpid
-ne
0
]
;
then
mail_room_status
=
"
$?
"
kill
-0
"
$mpid
"
2>/dev/null
else
mail_room_status
=
"
$?
"
mail_room_status
=
"-1"
else
mail_room_status
=
"-1"
fi
fi
fi
if
[
$web_status
=
0
-a
$sidekiq_status
=
0
-a
[
"
$mail_room_enabled
"
!=
true
||
$mail_room_status
=
0
]
]
;
then
if
[
$web_status
=
0
]
&&
[
$sidekiq_status
=
0
]
&&
{
[
"
$mail_room_enabled
"
!=
true
]
||
[
$mail_room_status
=
0
]
}
;
then
gitlab_status
=
0
gitlab_status
=
0
else
else
# http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
# http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
...
@@ -140,21 +142,21 @@ check_stale_pids(){
...
@@ -140,21 +142,21 @@ check_stale_pids(){
check_status
check_status
# If there is a pid it is something else than 0, the service is running if
# If there is a pid it is something else than 0, the service is running if
# *_status is == 0.
# *_status is == 0.
if
[
"
$wpid
"
!=
"0"
-a
"
$web_status
"
!=
"0"
]
;
then
if
[
"
$wpid
"
!=
"0"
]
&&
[
"
$web_status
"
!=
"0"
]
;
then
echo
"Removing stale Unicorn web server pid. This is most likely caused by the web server crashing the last time it ran."
echo
"Removing stale Unicorn web server pid. This is most likely caused by the web server crashing the last time it ran."
if
!
rm
"
$web_server_pid_path
"
;
then
if
!
rm
"
$web_server_pid_path
"
;
then
echo
"Unable to remove stale pid, exiting."
echo
"Unable to remove stale pid, exiting."
exit
1
exit
1
fi
fi
fi
fi
if
[
"
$spid
"
!=
"0"
-a
"
$sidekiq_status
"
!=
"0"
]
;
then
if
[
"
$spid
"
!=
"0"
]
&&
[
"
$sidekiq_status
"
!=
"0"
]
;
then
echo
"Removing stale Sidekiq job dispatcher pid. This is most likely caused by Sidekiq crashing the last time it ran."
echo
"Removing stale Sidekiq job dispatcher pid. This is most likely caused by Sidekiq crashing the last time it ran."
if
!
rm
"
$sidekiq_pid_path
"
;
then
if
!
rm
"
$sidekiq_pid_path
"
;
then
echo
"Unable to remove stale pid, exiting"
echo
"Unable to remove stale pid, exiting"
exit
1
exit
1
fi
fi
fi
fi
if
[
"
$mail_room_enabled
"
=
true
&&
"
$mpid
"
!=
"0"
-a
"
$mail_room_status
"
!=
"0"
]
;
then
if
[
"
$mail_room_enabled
"
=
true
]
&&
[
"
$mpid
"
!=
"0"
]
&&
[
"
$mail_room_status
"
!=
"0"
]
;
then
echo
"Removing stale MailRoom job dispatcher pid. This is most likely caused by MailRoom crashing the last time it ran."
echo
"Removing stale MailRoom job dispatcher pid. This is most likely caused by MailRoom crashing the last time it ran."
if
!
rm
"
$mail_room_pid_path
"
;
then
if
!
rm
"
$mail_room_pid_path
"
;
then
echo
"Unable to remove stale pid, exiting"
echo
"Unable to remove stale pid, exiting"
...
@@ -166,7 +168,7 @@ check_stale_pids(){
...
@@ -166,7 +168,7 @@ check_stale_pids(){
## If no parts of the service is running, bail out.
## If no parts of the service is running, bail out.
exit_if_not_running
(){
exit_if_not_running
(){
check_stale_pids
check_stale_pids
if
[
"
$web_status
"
!=
"0"
-a
"
$sidekiq_status
"
!=
"0"
-a
[
"
$mail_room_enabled
"
=
true
&&
"
$mail_room_status
"
!=
"0"
]
]
;
then
if
[
"
$web_status
"
!=
"0"
]
&&
[
"
$sidekiq_status
"
!=
"0"
]
&&
{
[
"
$mail_room_enabled
"
!=
true
]
||
[
"
$mail_room_status
"
!=
"0"
]
}
;
then
echo
"GitLab is not running."
echo
"GitLab is not running."
exit
exit
fi
fi
...
@@ -182,7 +184,7 @@ start_gitlab() {
...
@@ -182,7 +184,7 @@ start_gitlab() {
if
[
"
$sidekiq_status
"
!=
"0"
]
;
then
if
[
"
$sidekiq_status
"
!=
"0"
]
;
then
echo
-n
"Starting GitLab Sidekiq"
echo
-n
"Starting GitLab Sidekiq"
fi
fi
if
[
"
$mail_room_enabled
"
=
true
&&
"
$mail_room_status
"
!=
"0"
]
;
then
if
[
"
$mail_room_enabled
"
=
true
]
&&
[
"
$mail_room_status
"
!=
"0"
]
;
then
echo
-n
"Starting GitLab MailRoom"
echo
-n
"Starting GitLab MailRoom"
fi
fi
...
@@ -206,7 +208,7 @@ start_gitlab() {
...
@@ -206,7 +208,7 @@ start_gitlab() {
if
[
"
$mail_room_enabled
"
=
true
]
;
then
if
[
"
$mail_room_enabled
"
=
true
]
;
then
# If MailRoom is already running, don't start it again.
# If MailRoom is already running, don't start it again.
if
[
"
$mail_room_status
"
=
"0"
]
;
then
if
[
"
$mail_room_status
"
=
"0"
]
;
then
echo
"The MailRoom email processor is already running with pid
$
s
pid
, not restarting"
echo
"The MailRoom email processor is already running with pid
$
m
pid
, not restarting"
else
else
RAILS_ENV
=
$RAILS_ENV
bin/mail_room start &
RAILS_ENV
=
$RAILS_ENV
bin/mail_room start &
fi
fi
...
@@ -228,7 +230,7 @@ stop_gitlab() {
...
@@ -228,7 +230,7 @@ stop_gitlab() {
if
[
"
$sidekiq_status
"
=
"0"
]
;
then
if
[
"
$sidekiq_status
"
=
"0"
]
;
then
echo
-n
"Shutting down GitLab Sidekiq"
echo
-n
"Shutting down GitLab Sidekiq"
fi
fi
if
[
"
$mail_room_enabled
"
=
true
&&
"
$mail_room_status
"
=
"0"
]
;
then
if
[
"
$mail_room_enabled
"
=
true
]
&&
[
"
$mail_room_status
"
=
"0"
]
;
then
echo
-n
"Shutting down GitLab MailRoom"
echo
-n
"Shutting down GitLab MailRoom"
fi
fi
...
@@ -241,16 +243,16 @@ stop_gitlab() {
...
@@ -241,16 +243,16 @@ stop_gitlab() {
RAILS_ENV
=
$RAILS_ENV
bin/background_jobs stop
RAILS_ENV
=
$RAILS_ENV
bin/background_jobs stop
fi
fi
# And do the same thing for the MailRoom.
# And do the same thing for the MailRoom.
if
[
"
$mail_room_enabled
"
=
true
&&
"
$mail_room_status
"
=
"0"
]
;
then
if
[
"
$mail_room_enabled
"
=
true
]
&&
[
"
$mail_room_status
"
=
"0"
]
;
then
RAILS_ENV
=
$RAILS_ENV
bin/mail_room stop
RAILS_ENV
=
$RAILS_ENV
bin/mail_room stop
fi
fi
# If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script.
# If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script.
while
[
"
$web_status
"
=
"0"
-o
"
$sidekiq_status
"
=
"0"
-o
[
"
$mail_room_enabled
"
=
true
&&
"
$mail_room_status
"
=
"0"
]
]
;
do
while
[
"
$web_status
"
=
"0"
]
||
[
"
$sidekiq_status
"
=
"0"
]
||
{
[
"
$mail_room_enabled
"
=
true
]
&&
[
"
$mail_room_status
"
=
"0"
]
}
;
do
sleep
1
sleep
1
check_status
check_status
printf
"."
printf
"."
if
[
"
$web_status
"
!=
"0"
-a
"
$sidekiq_status
"
!=
"0"
-a
[
"
$mail_room_enabled
"
!=
true
||
"
$mail_room_status
"
!=
"0"
]
]
;
then
if
[
"
$web_status
"
!=
"0"
]
&&
[
"
$sidekiq_status
"
!=
"0"
]
&&
{
[
"
$mail_room_enabled
"
!=
true
]
||
[
"
$mail_room_status
"
!=
"0"
]
}
;
then
printf
"
\n
"
printf
"
\n
"
break
break
fi
fi
...
@@ -270,7 +272,7 @@ stop_gitlab() {
...
@@ -270,7 +272,7 @@ stop_gitlab() {
## Prints the status of GitLab and it's components.
## Prints the status of GitLab and it's components.
print_status
()
{
print_status
()
{
check_status
check_status
if
[
"
$web_status
"
!=
"0"
-a
"
$sidekiq_status
"
!=
"0"
-a
[
"
$mail_room_enabled
"
!=
true
||
"
$mail_room_status
"
!=
"0"
]
]
;
then
if
[
"
$web_status
"
!=
"0"
]
&&
[
"
$sidekiq_status
"
!=
"0"
]
&&
{
[
"
$mail_room_enabled
"
!=
true
]
||
[
"
$mail_room_status
"
!=
"0"
]
}
;
then
echo
"GitLab is not running."
echo
"GitLab is not running."
return
return
fi
fi
...
@@ -291,7 +293,7 @@ print_status() {
...
@@ -291,7 +293,7 @@ print_status() {
printf
"The GitLab MailRoom email processor is
\0
33[31mnot running
\0
33[0m.
\n
"
printf
"The GitLab MailRoom email processor is
\0
33[31mnot running
\0
33[0m.
\n
"
fi
fi
end
end
if
[
"
$web_status
"
=
"0"
-a
"
$sidekiq_status
"
=
"0"
-a
[
"
$mail_room_enabled
"
!=
true
||
"
$mail_room_status
"
=
"0"
]
]
;
then
if
[
"
$web_status
"
=
"0"
]
&&
[
"
$sidekiq_status
"
=
"0"
]
&&
{
[
"
$mail_room_enabled
"
!=
true
]
||
[
"
$mail_room_status
"
=
"0"
]
}
;
then
printf
"GitLab and all its components are
\0
33[32mup and running
\0
33[0m.
\n
"
printf
"GitLab and all its components are
\0
33[32mup and running
\0
33[0m.
\n
"
fi
fi
}
}
...
@@ -322,7 +324,7 @@ reload_gitlab(){
...
@@ -322,7 +324,7 @@ reload_gitlab(){
## Restarts Sidekiq and Unicorn.
## Restarts Sidekiq and Unicorn.
restart_gitlab
(){
restart_gitlab
(){
check_status
check_status
if
[
"
$web_status
"
=
"0"
-o
"
$sidekiq_status
"
=
"0"
-o
[
"
$mail_room_enabled
"
=
true
&&
"
$mail_room_status
"
=
"0"
]
]
;
then
if
[
"
$web_status
"
=
"0"
]
||
[
"
$sidekiq_status
"
=
"0"
]
||
{
[
"
$mail_room_enabled
"
=
true
]
&&
[
"
$mail_room_status
"
=
"0"
]
}
;
then
stop_gitlab
stop_gitlab
fi
fi
start_gitlab
start_gitlab
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment