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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
6a7d63aa
Commit
6a7d63aa
authored
Oct 09, 2013
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move unicorn and sidekiq commands into bash script
parent
7c4db532
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
27 deletions
+118
-27
lib/support/init.d/gitlab
lib/support/init.d/gitlab
+6
-7
lib/tasks/sidekiq.rake
lib/tasks/sidekiq.rake
+7
-20
script/background_jobs
script/background_jobs
+56
-0
script/web
script/web
+49
-0
No files found.
lib/support/init.d/gitlab
View file @
6a7d63aa
...
@@ -22,7 +22,6 @@ RAILS_ENV="production"
...
@@ -22,7 +22,6 @@ RAILS_ENV="production"
# /bin/sh variables such as PATH, EDITOR or SHELL.
# /bin/sh variables such as PATH, EDITOR or SHELL.
app_root
=
"/home/git/gitlab"
app_root
=
"/home/git/gitlab"
app_user
=
"git"
app_user
=
"git"
unicorn_conf
=
"
$app_root
/config/unicorn.rb"
pid_path
=
"
$app_root
/tmp/pids"
pid_path
=
"
$app_root
/tmp/pids"
socket_path
=
"
$app_root
/tmp/sockets"
socket_path
=
"
$app_root
/tmp/sockets"
web_server_pid_path
=
"
$pid_path
/unicorn.pid"
web_server_pid_path
=
"
$pid_path
/unicorn.pid"
...
@@ -129,7 +128,7 @@ start() {
...
@@ -129,7 +128,7 @@ start() {
# Remove old socket if it exists
# Remove old socket if it exists
rm
-f
"
$socket_path
"
/gitlab.socket 2>/dev/null
rm
-f
"
$socket_path
"
/gitlab.socket 2>/dev/null
# Start the webserver
# Start the webserver
bundle
exec
unicorn_rails
-D
-c
"
$unicorn_conf
"
-E
"
$RAILS_ENV
"
RAILS_ENV
=
$RAILS_ENV
script/web start
fi
fi
# If sidekiq is already running, don't start it again.
# If sidekiq is already running, don't start it again.
...
@@ -137,7 +136,7 @@ start() {
...
@@ -137,7 +136,7 @@ start() {
echo
"The Sidekiq job dispatcher is already running with pid
$spid
, not restarting"
echo
"The Sidekiq job dispatcher is already running with pid
$spid
, not restarting"
else
else
echo
"Starting the GitLab Sidekiq event dispatcher..."
echo
"Starting the GitLab Sidekiq event dispatcher..."
RAILS_ENV
=
$RAILS_ENV
bundle
exec
rake sidekiq:
start
RAILS_ENV
=
$RAILS_ENV
script/background_jobs
start
# We are sleeping a bit here because sidekiq is slow at writing it's pid
# We are sleeping a bit here because sidekiq is slow at writing it's pid
sleep
2
sleep
2
fi
fi
...
@@ -151,7 +150,7 @@ stop() {
...
@@ -151,7 +150,7 @@ stop() {
exit_if_not_running
exit_if_not_running
# If the Unicorn web server is running, tell it to stop;
# If the Unicorn web server is running, tell it to stop;
if
[
"
$web_status
"
=
"0"
]
;
then
if
[
"
$web_status
"
=
"0"
]
;
then
kill
-QUIT
"
$wpid
"
RAILS_ENV
=
$RAILS_ENV
script/web stop
echo
"Stopping the GitLab Unicorn web server..."
echo
"Stopping the GitLab Unicorn web server..."
stopping
=
true
stopping
=
true
else
else
...
@@ -160,7 +159,7 @@ stop() {
...
@@ -160,7 +159,7 @@ stop() {
# And do the same thing for the Sidekiq.
# And do the same thing for the Sidekiq.
if
[
"
$sidekiq_status
"
=
"0"
]
;
then
if
[
"
$sidekiq_status
"
=
"0"
]
;
then
printf
"Stopping Sidekiq job dispatcher."
printf
"Stopping Sidekiq job dispatcher."
RAILS_ENV
=
$RAILS_ENV
bundle
exec
rake sidekiq:
stop
RAILS_ENV
=
$RAILS_ENV
script/background_jobs
stop
stopping
=
true
stopping
=
true
else
else
echo
"The Sidekiq was not running, must have run out of breath."
echo
"The Sidekiq was not running, must have run out of breath."
...
@@ -215,10 +214,10 @@ reload(){
...
@@ -215,10 +214,10 @@ reload(){
exit
1
exit
1
fi
fi
printf
"Reloading GitLab Unicorn configuration... "
printf
"Reloading GitLab Unicorn configuration... "
kill
-USR2
"
$wpid
"
RAILS_ENV
=
$RAILS_ENV
script/web reload
echo
"Done."
echo
"Done."
echo
"Restarting GitLab Sidekiq since it isn't capable of reloading its config..."
echo
"Restarting GitLab Sidekiq since it isn't capable of reloading its config..."
RAILS_ENV
=
$RAILS_ENV
bundle
exec
rake sidekiq:
restart
RAILS_ENV
=
$RAILS_ENV
script/background_jobs
restart
# Waiting 2 seconds for sidekiq to write it.
# Waiting 2 seconds for sidekiq to write it.
sleep
2
sleep
2
status
status
...
...
lib/tasks/sidekiq.rake
View file @
6a7d63aa
namespace
:sidekiq
do
namespace
:sidekiq
do
desc
"GITLAB | Stop sidekiq"
desc
"GITLAB | Stop sidekiq"
task
:stop
do
task
:stop
do
system
"
bundle exec sidekiqctl stop
#{
pidfile
}
"
system
"
script/background_jobs stop
"
end
end
desc
"GITLAB | Start sidekiq"
desc
"GITLAB | Start sidekiq"
do
task
:start
=>
:restart
system
"script/background_jobs start"
desc
'GitLab | Restart sidekiq'
task
:restart
do
if
File
.
exist?
(
pidfile
)
puts
'Shutting down existing sidekiq process.'
Rake
::
Task
[
'sidekiq:stop'
].
invoke
puts
'Starting new sidekiq process.'
end
end
system
"bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e
#{
Rails
.
env
}
-P
#{
pidfile
}
-d -L
#{
log_file
}
>>
#{
log_file
}
2>&1"
desc
'GitLab | Restart sidekiq'
do
system
"script/background_jobs restart"
end
end
desc
"GITLAB | Start sidekiq with launchd on Mac OS X"
desc
"GITLAB | Start sidekiq with launchd on Mac OS X"
task
:launchd
do
task
:launchd
do
system
"bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e
#{
Rails
.
env
}
-P
#{
pidfile
}
>>
#{
log_file
}
2>&1"
system
"script/background_jobs start_no_deamonize"
end
def
pidfile
Rails
.
root
.
join
(
"tmp"
,
"pids"
,
"sidekiq.pid"
)
end
def
log_file
Rails
.
root
.
join
(
"log"
,
"sidekiq.log"
)
end
end
end
end
script/background_jobs
0 → 100755
View file @
6a7d63aa
#!/bin/bash
cd
$(
dirname
$0
)
/..
app_root
=
$(
pwd
)
sidekiq_pidfile
=
"
$app_root
/tmp/pids/sidekiq.pid"
sidekiq_logfile
=
"
$app_root
/log/sidekiq.log"
gitlab_user
=
$(
ls
-l
config.ru |
awk
'{print $3}'
)
function
stop
{
bundle
exec
sidekiqctl stop
$sidekiq_pidfile
&>>
$sidekiq_logfile
}
function
killall
{
pkill
-u
$gitlab_user
-f
sidekiq
}
function
restart
{
if
[
-f
$sidekiq_pidfile
]
;
then
stop
fi
killall
start_sidekiq
-d
-L
$sidekiq_logfile
}
function
start_no_deamonize
{
start_sidekiq
}
function
start_sidekiq
{
bundle
exec
sidekiq
-q
post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default
-e
$RAILS_ENV
-P
$sidekiq_pidfile
$@
&>>
$sidekiq_logfile
}
case
"
$1
"
in
stop
)
stop
;;
start
)
restart
;;
start_no_deamonize
)
start_no_deamonize
;;
restart
)
restart
;;
killall
)
killall
;;
*
)
echo
"Usage: RAILS_ENV=your_env
$0
{stop|start|start_no_deamonize|restart|killall}"
esac
script/web
0 → 100755
View file @
6a7d63aa
#!/bin/bash
cd
$(
dirname
$0
)
/..
app_root
=
$(
pwd
)
unicorn_pidfile
=
"
$app_root
/tmp/pids/unicorn.pid"
unicorn_config
=
"
$app_root
/config/unicorn.rb"
function
get_unicorn_pid
{
local
pid
=
$(
cat
$unicorn_pidfile
)
if
[
-z
$pid
]
;
then
echo
"Could not find a PID in
$unicorn_pidfile
"
exit
1
fi
unicorn_pid
=
$pid
}
function
start
{
bundle
exec
unicorn_rails
-D
-c
$unicorn_config
-E
$RAILS_ENV
}
function
stop
{
get_unicorn_pid
kill
-QUIT
$unicorn_pid
}
function
reload
{
get_unicorn_pid
kill
-USR2
$unicorn_pid
}
case
"
$1
"
in
start
)
start
;;
stop
)
stop
;;
reload
)
reload
;;
*
)
echo
"Usage: RAILS_ENV=your_env
$0
{start|stop|reload}"
;;
esac
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