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
|
|
|
|
|
2021-11-09 10:12:42 -05: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()
|
|
|
|
{
|
2021-11-09 10:12:42 -05:00
|
|
|
spawn_puma &
|
2021-05-21 23:10:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
start_foreground()
|
|
|
|
{
|
2021-11-09 10:12:42 -05:00
|
|
|
spawn_puma
|
2021-05-21 23:10:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
get_puma_pid
|
|
|
|
kill -INT "$(get_puma_pid)"
|
|
|
|
}
|
|
|
|
|
|
|
|
reload()
|
|
|
|
{
|
|
|
|
kill -USR2 "$(get_puma_pid)"
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2021-11-09 10:12:42 -05:00
|
|
|
start
|
2021-05-21 23:10:39 -04:00
|
|
|
;;
|
|
|
|
start_foreground)
|
2021-11-09 10:12:42 -05:00
|
|
|
start_foreground
|
2021-05-21 23:10:39 -04:00
|
|
|
;;
|
|
|
|
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
|