gitlab-org--gitlab-foss/bin/web
Jacob Vosmaer 8a6776caa9 Use 'exec' in Unicorn and Sidekiq launch scripts
When running Unicorn or Sidekiq in the foreground this change removes
an intermediate /bin/sh process. This makes process supervision in the
GitLab Development Kit more reliable.

This change does not affect Omnibus-GitLab (because there we do not
use these launch scripts). Installations from source do use the launch
scripts but for the standard GitLab init script this change will not
make a difference.

Custom installations using Upstart or Systemd may be affected however,
because under certain configurations these systems count exactly how
many forks happen during process startup, and we are reducing that
number by one here.
2016-04-28 12:11:08 +02:00

58 lines
798 B
Bash
Executable file

#!/bin/sh
cd $(dirname $0)/..
app_root=$(pwd)
unicorn_pidfile="$app_root/tmp/pids/unicorn.pid"
unicorn_config="$app_root/config/unicorn.rb"
unicorn_cmd="bundle exec unicorn_rails -c $unicorn_config -E $RAILS_ENV"
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
}
start()
{
exec $unicorn_cmd -D
}
start_foreground()
{
exec $unicorn_cmd
}
stop()
{
get_unicorn_pid
kill -QUIT $unicorn_pid
}
reload()
{
get_unicorn_pid
kill -USR2 $unicorn_pid
}
case "$1" in
start)
start
;;
start_foreground)
start_foreground
;;
stop)
stop
;;
reload)
reload
;;
*)
echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}"
;;
esac