Since this post has gotten a lot of attention over the years, I\'ve listed the top solutions per platform at the bottom of this post.
Original post
If you are running OSX, then the easiest way to produce a true system process is to use launchd
to launch it.
Build a plist like this, and put it into the /Library/LaunchDaemons with the name top-level-domain.your-domain.application.plist
(you need to be root when placing it):
Label
top-level-domain.your-domain.application
WorkingDirectory
/your/preferred/workingdirectory
ProgramArguments
/usr/local/bin/node
your-script-file
RunAtLoad
KeepAlive
When done, issue this (as root):
launchctl load /Library/LaunchDaemons/top-level-domain.your-domain.application.plist
launchctl start top-level-domain.your-domain.application
and you are running.
And you will still be running after a restart.
For other options in the plist look at the man page here: https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man5/launchd.plist.5.html