2014-07-04 03:45:20 -04:00
|
|
|
#!/bin/sh
|
2013-10-09 10:45:32 -04:00
|
|
|
|
2019-07-03 00:11:48 -04:00
|
|
|
set -e
|
|
|
|
|
2013-10-09 10:45:32 -04:00
|
|
|
cd $(dirname $0)/..
|
2021-05-21 23:10:39 -04:00
|
|
|
app_root=$(pwd)
|
2013-10-09 10:45:32 -04:00
|
|
|
|
2021-05-21 23:10:39 -04:00
|
|
|
puma_pidfile="$app_root/tmp/pids/puma.pid"
|
|
|
|
puma_config="$app_root/config/puma.rb"
|
2013-10-09 10:45:32 -04:00
|
|
|
|
2021-05-21 23:10:39 -04:00
|
|
|
spawn_puma()
|
|
|
|
{
|
|
|
|
exec bundle exec puma --config "${puma_config}" --environment "$RAILS_ENV" "$@"
|
|
|
|
}
|
2013-10-09 10:45:32 -04:00
|
|
|
|
2021-05-21 23:10:39 -04:00
|
|
|
get_puma_pid()
|
|
|
|
{
|
|
|
|
pid=$(cat "${puma_pidfile}")
|
|
|
|
if [ -z "$pid" ] ; then
|
|
|
|
echo "Could not find a PID in $puma_pidfile"
|
2020-05-25 11:07:58 -04:00
|
|
|
exit 1
|
2021-05-21 23:10:39 -04:00
|
|
|
fi
|
|
|
|
echo "${pid}"
|
|
|
|
}
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
|
|
|
spawn_puma &
|
|
|
|
}
|
|
|
|
|
|
|
|
start_foreground()
|
|
|
|
{
|
|
|
|
spawn_puma
|
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
get_puma_pid
|
|
|
|
kill -INT "$(get_puma_pid)"
|
|
|
|
}
|
|
|
|
|
|
|
|
reload()
|
|
|
|
{
|
|
|
|
kill -USR2 "$(get_puma_pid)"
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
start_foreground)
|
|
|
|
start_foreground
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
reload
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}"
|
2020-05-25 11:07:58 -04:00
|
|
|
;;
|
2013-10-09 10:45:32 -04:00
|
|
|
esac
|