2014-09-23 23:37:15 +02:00
|
|
|
#!/sbin/runscript
|
|
|
|
|
|
|
|
name="GitLab CI"
|
|
|
|
description="GitLab CI on Unicorns"
|
|
|
|
|
|
|
|
: ${gitlab_ci_user:=@USER@}
|
|
|
|
: ${gitlab_ci_base:="@GITLAB_CI_BASE@"}
|
|
|
|
: ${rails_env:=production}
|
|
|
|
|
|
|
|
: ${server_pidfile:="@RUN_DIR@/unicorn.pid"}
|
|
|
|
|
|
|
|
: ${sidekiq_pidfile:="@RUN_DIR@/sidekiq.pid"}
|
|
|
|
: ${sidekiq_logfile:="@LOGS_DIR@/sidekiq.log"}
|
|
|
|
: ${sidekiq_queues:="@QUEUES@"}
|
|
|
|
|
|
|
|
server_command="/usr/bin/bundle"
|
|
|
|
server_command_args="exec unicorn_rails -c ${gitlab_ci_base}/config/unicorn.rb -E ${rails_env} -D"
|
|
|
|
|
|
|
|
sidekiq_command="/usr/bin/bundle"
|
|
|
|
sidekiq_command_args="exec sidekiq -q ${sidekiq_queues} -P ${sidekiq_pidfile} -L ${sidekiq_logfile}"
|
|
|
|
|
|
|
|
depend() {
|
|
|
|
provide gitlab-ci
|
|
|
|
need redis
|
|
|
|
use net
|
2014-10-20 00:34:38 +02:00
|
|
|
after bootmisc
|
2014-09-23 23:37:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
ebegin "Starting ${name} - Unicorn servers"
|
|
|
|
|
|
|
|
checkpath -d -o ${gitlab_ci_user} -m755 "$(dirname "${server_pidfile}")"
|
|
|
|
checkpath -d -o ${gitlab_ci_user} -m755 "$(dirname "${sidekiq_pidfile}")"
|
|
|
|
|
|
|
|
start-stop-daemon --start \
|
|
|
|
--chdir "${gitlab_ci_base}" \
|
|
|
|
--user=${gitlab_ci_user} \
|
|
|
|
--pidfile="${server_pidfile}" \
|
|
|
|
--env RAILS_ENV=${rails_env} \
|
|
|
|
--exec ${server_command} -- ${server_command_args}
|
|
|
|
eend $?
|
|
|
|
|
|
|
|
ebegin "Starting ${name} - Sidekiq"
|
|
|
|
|
|
|
|
start-stop-daemon --start \
|
|
|
|
--background --quiet \
|
|
|
|
--chdir "${gitlab_ci_base}" \
|
|
|
|
--user=${gitlab_ci_user} \
|
|
|
|
--pidfile="${sidekiq_pidfile}" \
|
|
|
|
--env RAILS_ENV=${rails_env} \
|
|
|
|
--exec ${sidekiq_command} -- ${sidekiq_command_args}
|
|
|
|
eend $?
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
ebegin "Stopping ${name} - Sidekiq"
|
|
|
|
start-stop-daemon --stop \
|
|
|
|
--pidfile=${sidekiq_pidfile} \
|
|
|
|
--exec ${sidekiq_command}
|
|
|
|
eend $?
|
|
|
|
|
|
|
|
ebegin "Stopping ${name} - Unicorn servers"
|
|
|
|
start-stop-daemon --stop \
|
|
|
|
--signal QUIT \
|
|
|
|
--pidfile=${server_pidfile} \
|
|
|
|
--exec ${server_command}
|
|
|
|
eend $?
|
|
|
|
}
|