akkoma/installation/netbsd/rc.d/akkoma

58 lines
961 B
Text
Raw Normal View History

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