Sha256: 011e63f5a82bef3c91f159526cd84ddc6ccd20b3d0f77f5308cc0bc06e3b0b33

Contents?: true

Size: 1.55 KB

Versions: 69

Compression:

Stored size: 1.55 KB

Contents

#!/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")
				su - $user -c "cd $dir && rbenv shell $rb_ver && bundle exec puma -C $dir/config/puma.rb -d"
				;;
			*)
				;;
		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")
				su - $user -c "cd $dir && pkill ruby && rbenv shell $ruby_version && bundle exec puma -C $dir/config/puma.rb -d"
				;;
			*)
				;;
		esac
		i=$(( i + 1 ))
	done
}

load_rc_config $name
run_rc_command "$1"

Version data entries

69 entries across 69 versions & 5 rubygems

Version Path
puma-4.3.12-java tools/jungle/rc.d/puma
puma-4.3.12 tools/jungle/rc.d/puma
puma-4.3.11-java tools/jungle/rc.d/puma
puma-4.3.11 tools/jungle/rc.d/puma
puma-4.3.10-java tools/jungle/rc.d/puma
puma-4.3.10 tools/jungle/rc.d/puma
puma-4.3.9 tools/jungle/rc.d/puma
puma-4.3.9-java tools/jungle/rc.d/puma
puma-4.3.8-java tools/jungle/rc.d/puma
puma-4.3.8 tools/jungle/rc.d/puma
puma-4.3.7-java tools/jungle/rc.d/puma
puma-4.3.7 tools/jungle/rc.d/puma
piesync-puma-3.12.6.1 tools/jungle/rc.d/puma
piesync-puma-3.12.6 tools/jungle/rc.d/puma
puma-5.0.2-java docs/jungle/rc.d/puma
puma-5.0.2 docs/jungle/rc.d/puma
puma-5.0.1-java docs/jungle/rc.d/puma
puma-5.0.1 docs/jungle/rc.d/puma
puma-5.0.0-java docs/jungle/rc.d/puma
puma-5.0.0 docs/jungle/rc.d/puma