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