Simplify the NetBSD rc script.

This commit is contained in:
scarlett 2018-12-16 13:11:17 +00:00
parent 9d3eda1959
commit 4b40e4188c

View File

@ -9,34 +9,25 @@ fi
name="pleroma" name="pleroma"
rcvar=${name} rcvar=${name}
command="/usr/pkg/bin/elixir" command="/usr/pkg/bin/elixir"
command_args="/usr/pkg/bin/mix phx.server &" command_args="--detached -S /usr/pkg/bin/mix phx.server"
start_cmd=pleroma_start
start_precmd="ulimit -n unlimited" start_precmd="ulimit -n unlimited"
pidfile="${pleroma_home}/pleroma/pid" pidfile="/dev/null"
pleroma_chdir="${pleroma_home}/pleroma" pleroma_chdir="${pleroma_home}/pleroma"
pleroma_env="HOME=${pleroma_home} MIX_ENV=prod" pleroma_env="HOME=${pleroma_home} MIX_ENV=prod"
pleroma_user="pleroma"
pleroma_start()
{
echo "Starting ${name}."
${start_precmd}
su -m ${pleroma_user} -c "cd ${pleroma_chdir} && \
${pleroma_env} ${command} ${command_args}"
echo $! > ${pidfile}
}
check_pidfile() check_pidfile()
{ {
read _pid _junk < ${pidfile} pid=$(pgrep -U "${pleroma_user}" /bin/beam.smp$)
echo -n "$(ps -axo pid | grep ${_pid})" echo -n "${pid}"
} }
if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then # newer NetBSD if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
# newer NetBSD
load_rc_config ${name} load_rc_config ${name}
run_rc_command "$1" run_rc_command "$1"
else # ancient NetBSD, Solaris and illumos, Linux, etc... else
# ancient NetBSD, Solaris and illumos, Linux, etc...
cmd=${1:-start} cmd=${1:-start}
case ${cmd} in case ${cmd} in
@ -47,8 +38,8 @@ else # ancient NetBSD, Solaris and illumos, Linux, etc...
stop) stop)
echo "Stopping ${name}." echo "Stopping ${name}."
kill `cat ${pidfile}` check_pidfile
rm ${pidfile} ! [ -n ${pid} ] && kill ${pid}
;; ;;
restart) restart)