Hi,
I am playing around with node.js and want it to start at boot-time. I've made a primitive rc.d script, which works fine by using the typical commands, such as
I followed the handbook and looked at some of the base scripts. But I can't find the solution.
The rc script is saved in
In
This is the scripts content:
(I know, the stop and restart functions are weird, but on time I will make proper scripts to gracefully stop or restart the app)
What could be the reason it's prevented from beeing started at boot time?
Kind regards
Zabrah
I am playing around with node.js and want it to start at boot-time. I've made a primitive rc.d script, which works fine by using the typical commands, such as
service miniserver start
. But on system startup my app do not start.I followed the handbook and looked at some of the base scripts. But I can't find the solution.
The rc script is saved in
/usr/local/etc/rc.d/miniserver
have the rights -rwxr-xr-x
with owner root:wheel
In
/etc/rc.conf
I have added miniserver_enable="YES"
This is the scripts content:
Bash:
#!/bin/sh
# PROVIDE: miniserver
# REQUIRE: DAEMON NETWORKING FILESYSTEMS
# BEFORE: LOGIN
# KEYWORD:
. /etc/rc.subr
name="miniserver"
rcvar="miniserver_enable"
start_cmd=miniserver_start
stop_cmd=miniserver_stop
restart_cmd=miniserver_restart
pidfile="/var/run/miniserver.pid"
miniserver_start()
{
NODE_ENV=production
daemon -u www -t "Miniserver Daemon" -P "/var/run/miniserver.pid" /usr/local/bin/node /www/miniserver/start.js
echo "Miniserver started"
}
miniserver_stop()
{
miniserver_pid=`cat /var/run/miniserver.pid`
kill $miniserver_pid
echo "Miniserver stopped"
}
miniserver_restart()
{
miniserver_stop
miniserver_start
echo "Miniserver restarted"
}
load_rc_config "miniserver"
run_rc_command "$1"
What could be the reason it's prevented from beeing started at boot time?
Kind regards
Zabrah