2015-03-25 22:45:19 +01:00
|
|
|
#!/sbin/runscript
|
|
|
|
|
|
|
|
name="GitLab"
|
2015-03-26 13:09:56 +01:00
|
|
|
description="GitLab 7.9 on Unicorns"
|
2015-03-25 22:45:19 +01:00
|
|
|
|
|
|
|
: ${gitlab_user:=git}
|
|
|
|
: ${gitlab_group:=git}
|
2015-03-26 13:09:56 +01:00
|
|
|
: ${gitlab_home:="/opt/gitlabhq-7.9"}
|
2015-03-25 22:45:19 +01:00
|
|
|
|
2015-03-26 13:09:56 +01:00
|
|
|
: ${server_pidfile:="/opt/gitlabhq-7.9/tmp/pids/unicorn.pid"}
|
|
|
|
: ${sidekiq_pidfile:="/opt/gitlabhq-7.9/tmp/pids/sidekiq.pid"}
|
2015-03-25 22:45:19 +01:00
|
|
|
|
2015-03-26 13:09:56 +01:00
|
|
|
: ${sidekiq_log:="/var/log/gitlabhq-7.9/sidekiq.log"}
|
2015-03-25 22:45:19 +01:00
|
|
|
|
|
|
|
: ${rails_env:=production}
|
|
|
|
|
|
|
|
server_command="/usr/bin/bundle"
|
|
|
|
server_command_args="exec unicorn_rails -c ${gitlab_home}/config/unicorn.rb -E ${rails_env} -D"
|
|
|
|
sidekiq_command="/usr/bin/bundle"
|
|
|
|
sidekiq_start_command_args="exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e ${rails_env} -P ${sidekiq_pidfile} -d -L ${sidekiq_log} >> ${sidekiq_log}"
|
|
|
|
sidekiq_stop_command_args="exec sidekiqctl stop ${sidekiq_pidfile} >> ${sidekiq_log}"
|
|
|
|
|
|
|
|
if [ ${rails_env} = development ]; then
|
|
|
|
sidekiq_command_args+=" VVERBOSE=1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
depend() {
|
|
|
|
provide gitlab
|
|
|
|
need redis
|
|
|
|
use net
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
2015-03-26 13:09:56 +01:00
|
|
|
ebegin "Starting GitLab 7.9 Unicorn servers"
|
2015-03-25 22:45:19 +01:00
|
|
|
|
|
|
|
checkpath -d -o "${gitlab_user}:${gitlab_group}" -m750 "$(dirname "${server_pidfile}")"
|
|
|
|
checkpath -d -o "${gitlab_user}:${gitlab_group}" -m750 "$(dirname "${sidekiq_pidfile}")"
|
|
|
|
|
|
|
|
start-stop-daemon --start \
|
|
|
|
--chdir "${gitlab_home}" \
|
|
|
|
--user="${gitlab_user}:${gitlab_group}" \
|
|
|
|
--pidfile="${server_pidfile}" \
|
|
|
|
--exec ${server_command} -- ${server_command_args}
|
|
|
|
eend $?
|
|
|
|
|
2015-03-26 13:09:56 +01:00
|
|
|
ebegin "Starting GitLab 7.9 Sidekiq"
|
2015-03-25 22:45:19 +01:00
|
|
|
cd "${gitlab_home}"
|
|
|
|
sudo -u git -H ${sidekiq_command} ${sidekiq_start_command_args}
|
|
|
|
eend $?
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2015-03-26 13:09:56 +01:00
|
|
|
ebegin "Stopping GitLab 7.9 Sidekiq"
|
2015-03-25 22:45:19 +01:00
|
|
|
cd "${gitlab_home}"
|
|
|
|
sudo -u git -H ${sidekiq_command} ${sidekiq_stop_command_args}
|
|
|
|
eend $?
|
|
|
|
|
2015-03-26 13:09:56 +01:00
|
|
|
ebegin "Stopping GitLab 7.9 Unicorn servers"
|
2015-03-25 22:45:19 +01:00
|
|
|
start-stop-daemon --stop \
|
|
|
|
--chdir "${gitlab_home}" \
|
|
|
|
--user="${gitlab_user}:${gitlab_group}" \
|
|
|
|
--pidfile="${server_pidfile}"
|
|
|
|
eend $?
|
|
|
|
}
|