I have developed the following script at location /usr/local/etc/rc.d/bluesky
#!/bin/sh # PROVIDE: bluesky # REQUIRE: mysql sshd # BEFORE: # KEYWORD: . /etc/rc.subr name="bluesky" rcvar=bluesky_enable start_cmd="${name}_start" stop_cmd=":" load_rc_config $name : ${bluesky_enable:=no} : ${bluesky_msg="HTTP server starts ..."} bluesky_start(){ echo $PATH export PATH=$PATH:/usr/local/bin/ echo $PATH ### Run Node server ### /usr/local/bin/node /usr/home/ict/Documents/bluesky/server.js echo "$bluesky_msg" } run_rc_command "$1" I also have enabled it on my /etc/rc.conf file:
bluesky_enable="YES" When I reboot the server, the script works fine and starts the HTTP server at port 80. The only problem is that the script won't be sent to background or won't be started as a daemon. I wonder how I can run script at boot time in the background or as a daemon.