youjo-be/installation/netbsd/rc.d/akkoma

58 lines
988 B
Text
Raw Normal View History

2018-12-16 13:33:50 +01:00
#!/bin/sh
# PROVIDE: akkoma
2018-12-16 13:33:50 +01:00
# REQUIRE: DAEMON pgsql
if [ -f /etc/rc.subr ]; then
. /etc/rc.subr
fi
name="akkoma"
2018-12-16 13:33:50 +01:00
rcvar=${name}
command="/usr/pkg/bin/elixir"
2018-12-16 14:11:17 +01:00
command_args="--detached -S /usr/pkg/bin/mix phx.server"
2018-12-16 13:33:50 +01:00
start_precmd="ulimit -n unlimited"
2018-12-16 14:11:17 +01:00
pidfile="/dev/null"
2018-12-16 13:33:50 +01:00
akkoma_chdir="${akkoma_home}/akkoma"
akkoma_env="HOME=${akkoma_home} MIX_ENV=prod ERL_EPMD_ADDRESS=127.0.0.1"
2018-12-16 13:33:50 +01:00
check_pidfile()
{
pid=$(pgrep -U "${akkoma_user}" /bin/beam.smp$)
2018-12-16 14:11:17 +01:00
echo -n "${pid}"
2018-12-16 13:33:50 +01:00
}
2018-12-16 14:11:17 +01:00
if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
# newer NetBSD
2018-12-16 13:33:50 +01:00
load_rc_config ${name}
run_rc_command "$1"
2018-12-16 14:11:17 +01:00
else
# ancient NetBSD, Solaris and illumos, Linux, etc...
2018-12-16 13:33:50 +01:00
cmd=${1:-start}
case ${cmd} in
start)
echo "Starting ${name}."
${start_cmd}
;;
stop)
echo "Stopping ${name}."
2018-12-16 14:11:17 +01:00
check_pidfile
! [ -n ${pid} ] && kill ${pid}
2018-12-16 13:33:50 +01:00
;;
restart)
( $0 stop )
sleep 5
$0 start
;;
*)
echo 1>&2 "Usage: $0 [start|stop|restart]"
exit 1
;;
esac
exit 0
fi