#!/bin/sh
#
# $NetBSD: redmine51_unicorn.sh,v 1.1 2023/11/29 16:10:19 taca Exp $
#

# PROVIDE: redmine51_unicorn32
# REQUIRE: DAEMON
# KEYWORD: shutdown

if [ -f /etc/rc.subr ]; then
	$_rc_subr_loaded . /etc/rc.subr
fi

name="redmine51_unicorn32"
rcvar=$name
start_cmd="redmine51_unicorn_start"
stop_cmd="redmine51_unicorn_stop"

redmine51_unicorn_start()
{
	cd /usr/pkg/share/ruby32-redmine51
	/usr/pkg/bin/bundle32 exec /usr/pkg/bin/unicorn32 \
		-c /usr/pkg/share/ruby32-redmine51/config/unicorn.rb \
		-E production -D
}

redmine51_unicorn_stop()
{
	/bin/kill -QUIT `/bin/cat /usr/pkg/share/ruby32-redmine51/unicorn.pid`
}

load_rc_config $name
run_rc_command "$1"
