I'm having two issues with following rc script (some commands trimmed for brevity):
First is that processes started from it are always by the user that started the service (say, "sudo service sfile start" will start processes as root). I thought ${name}_user in script or in rc.conf should override the user running it?
Second is at boot, in that, though it does start the script, no processes get started by it, unlike when ran in some login shell. sfile_enable="YES" is set in /etc/rc.conf as well as rc_debug, which gives me no particular relevant information.
Code:
#!/bin/sh
# PROVIDE: sfile
# REQUIRE: NETWORKING SERVERS DAEMON LOGIN
# KEYWORD: shutdown
. /etc/rc.subr
name=sfile
rcvar=sfile_enable
load_rc_config $name
: ${sfile_enable=NO}
: ${sfile_user=synthmeat}
: ${sfile_group=synthmeat}
sfile_node=/usr/local/bin/node
sfile_workdir=/home/synthmeat/work/showdown-file
sfile_script=build/main.js
sfile_logfile=/home/synthmeat/logs/showdown-file.log
sfile_pidfile=/home/synthmeat/pids/showdown-file.pid
start_cmd=sfile_start
sfile_start()
{
if [ -e ${sfile_pidfile} ]
then
if [ `pgrep -F ${sfile_pidfile}` ]
then echo 'showdown file server is already running'
else
echo 'starting showdown file server'
cd ${sfile_workdir}
nohup ${sfile_node} ${sfile_script} > ${sfile_logfile} 2>&1 &
fi
else
echo 'starting showdown file server'
cd ${sfile_workdir}
nohup ${sfile_node} ${sfile_script} > ${sfile_logfile} 2>&1 &
fi
}
run_rc_command "$1"
First is that processes started from it are always by the user that started the service (say, "sudo service sfile start" will start processes as root). I thought ${name}_user in script or in rc.conf should override the user running it?
Second is at boot, in that, though it does start the script, no processes get started by it, unlike when ran in some login shell. sfile_enable="YES" is set in /etc/rc.conf as well as rc_debug, which gives me no particular relevant information.