#!/sbin/runscript name="GitLab" description="GitLab 8.3 on Unicorns" : ${gitlab_user:=git} : ${gitlab_group:=git} : ${gitlab_home:="/opt/gitlabhq-8.3"} : ${gitlab_log:="/var/log/gitlabhq-8.3"} : ${unicorn_pidfile:="${gitlab_home}/tmp/pids/unicorn.pid"} : ${unicorn_log:="${gitlab_log}/unicorn.log"} : ${sidekiq_pidfile:="${gitlab_home}/tmp/pids/sidekiq.pid"} : ${sidekiq_log:="${gitlab_log}/sidekiq.log"} : ${workhorse_pidfile:="${gitlab_home}/tmp/pids/workhorse.pid"} : ${workhorse_log:="${gitlab_log}/workhorse.log"} : ${workhorse_socket:="${gitlab_home}/tmp/sockets/gitlab-workhorse.socket"} : ${rails_env:=production} unicorn_command="/usr/bin/bundle" unicorn_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 -c 10 -q post_receive -q mailer -q archive_repo -q system_hook -q project_web_hook -q gitlab_shell -q incoming_email -q runner -q common -q default -e ${rails_env} -d -P ${sidekiq_pidfile} -L ${sidekiq_log} $@ >> ${sidekiq_log} 2>&1" sidekiq_stop_command_args="exec sidekiqctl stop ${sidekiq_pidfile} >> ${sidekiq_log}" workhorse_command="/usr/bin/gitlab-workhorse" workhorse_command_args="-listenUmask 0 -listenNetwork unix -listenAddr ${workhorse_socket} -authBackend http://127.0.0.1:8080" if [ ${rails_env} = development ]; then sidekiq_command_args+=" VVERBOSE=1" fi depend() { provide gitlab need redis use net mysql postgresql } start() { checkpath -d -o "${gitlab_user}:${gitlab_group}" -m750 "$(dirname "${unicorn_pidfile}")" checkpath -d -o "${gitlab_user}:${gitlab_group}" -m750 "$(dirname "${sidekiq_pidfile}")" ebegin "Starting GitLab 8.3 Unicorn servers" start-stop-daemon --start \ --chdir "${gitlab_home}" \ --user="${gitlab_user}:${gitlab_group}" \ --pidfile="${unicorn_pidfile}" \ --exec ${unicorn_command} -- ${unicorn_command_args} eend $? ebegin "Starting GitLab 8.3 Sidekiq" cd "${gitlab_home}" sudo -u git -H ${sidekiq_command} ${sidekiq_start_command_args} eend $? ebegin "Starting GitLab 8.3 Workhorse" start-stop-daemon --start \ --chdir "${gitlab_home}" \ --user="${gitlab_user}:${gitlab_group}" \ --pidfile="${workhorse_pidfile}" \ --background -1 "${workhorse_log}" -2 "${workhorse_log}" \ --exec ${workhorse_command} -- ${workhorse_command_args} eend $? } stop() { ebegin "Stopping GitLab 8.3 Workhorse" start-stop-daemon --stop \ --chdir "${gitlab_home}" \ --user="${gitlab_user}:${gitlab_group}" \ --pidfile="${workhorse_pidfile}" eend $? ebegin "Stopping GitLab 8.3 Sidekiq" cd "${gitlab_home}" sudo -u git -H ${sidekiq_command} ${sidekiq_stop_command_args} eend $? ebegin "Stopping GitLab 8.3 Unicorn servers" start-stop-daemon --stop \ --chdir "${gitlab_home}" \ --user="${gitlab_user}:${gitlab_group}" \ --pidfile="${unicorn_pidfile}" eend $? }