The canonical way to create system services are using rc.d system. While those scripts are easy to write, thanks to this guide, I've run into several issues having my script to run correctly. That is although I can manually start the service (as root) with /etc/rc.d/myservice start (maybe I should try service myservice start next time?), when the system boots, it fails to run, due to errors like, bash couldn't be found, node couldn't be found.

I've better luck with crontab though. The nice thing is I get to reuse the script I wrote for the rc.d. I just install a crontab line @reboot path/to/script start:

[root@bsd /usr/jails/tiddly/var/cron/tabs]# cat root
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.3lLCXYWdq3 installed on Thu Feb  9 21:07:27 2017)
# (Cron version -- $FreeBSD: releng/11.0/usr.sbin/cron/crontab/crontab.c 305427                                                                                                          2016-09-05 16:43:57Z emaste $)
@reboot /root/wiki/wiki start

Normally a daemon can be created by putting this in shell script:

(nohup /path/to/daemon.sh >> log_file 2>&1 &)

Quoted from one of the comments:

The parentheses in (nohup sleep 20 &) do make a difference. They specify a sub-shell. Inside the sub-shell, the nohup command executes the sleep command in the background. When it returns, the sub-shell exits, so the sleep is orphaned, no longer 'owned' by the current shell.

Refer to this awesome SO post.

Another way that's more awesome is to use screen:

screen -d -m /path/to/daemon.sh

screen runs the script and then detaches. What's cool about this approach is that at any time, you can reattach to the screen session and interact with the daemon! I need to figure out a way make daemon.sh also produces logs.