1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/docs/jungle/rc.d/puma
Felix ddbeda76b4
Cleanup daemonization in rc.d script (#2409)
Pull request https://github.com/puma/puma/pull/2170/files
removed all daemonization code.
The `-d` in the rc.d scripts is a left over from this.
This is replaces by `daemon` (https://www.freebsd.org/cgi/man.cgi?query=daemon&sektion=8)
for daemonization of the process.

Signed-off-by: fliiiix <hi@l33t.name>
2020-10-03 08:03:35 -06:00

61 lines
1.5 KiB
Bash
Executable file

#!/bin/sh
#
# PROVIDE: puma
. /etc/rc.subr
name="puma"
start_cmd="puma_start"
stop_cmd="puma_stop"
restart_cmd="puma_restart"
rcvar=puma_enable
required_files=/usr/local/etc/puma.conf
puma_start()
{
server_count=$(/usr/local/bin/jq ".servers[] .ruby_env" /usr/local/etc/puma.conf | wc -l)
i=0
while [ "$i" -lt "$server_count" ]; do
rb_env=$(/usr/local/bin/jq -r ".servers[$i].ruby_env" /usr/local/etc/puma.conf)
dir=$(/usr/local/bin/jq -r ".servers[$i].dir" /usr/local/etc/puma.conf)
user=$(/usr/local/bin/jq -r ".servers[$i].user" /usr/local/etc/puma.conf)
rb_ver=$(/usr/local/bin/jq -r ".servers[$i].ruby_version" /usr/local/etc/puma.conf)
case $rb_env in
"rbenv")
cd $dir && rbenv shell $rb_ver && /usr/sbin/daemon -u $user bundle exec puma -C $dir/config/puma.rb
;;
*)
;;
esac
i=$(( i + 1 ))
done
}
puma_stop()
{
pkill ruby
}
puma_restart()
{
server_count=$(/usr/local/bin/jq ".servers[] .ruby_env" /usr/local/etc/puma.conf | wc -l)
i=0
while [ "$i" -lt "$server_count" ]; do
rb_env=$(/usr/local/bin/jq -r ".servers[$i].ruby_env" /usr/local/etc/puma.conf)
dir=$(/usr/local/bin/jq -r ".servers[$i].dir" /usr/local/etc/puma.conf)
user=$(/usr/local/bin/jq -r ".servers[$i].user" /usr/local/etc/puma.conf)
rb_ver=$(/usr/local/bin/jq -r ".servers[$i].ruby_version" /usr/local/etc/puma.conf)
case $rb_env in
"rbenv")
cd $dir && rbenv shell $rb_ver && /usr/sbin/daemon -u $user bundle exec puma -C $dir/config/puma.rb
;;
*)
;;
esac
i=$(( i + 1 ))
done
}
load_rc_config $name
run_rc_command "$1"