node.js run with root privileges on MacOS on start
How long it’s quite easy to setup init.d services on linux boxes, same task on Max OS machines is pretty hard. Especially if you need to run it with root privileges.
Create file
/Library/LaunchDaemons/com.spidersoft.cms.plist
Content of this file should be like that:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>OnDemand</key>
<false/>
<key>Label</key>
<string>com.imagination.cms</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/node</string>
<string>/usr/local/bin/forever</string>
<string>-a</string>
<string>-l</string>
<string>/Users/admin/Documents/cms/app.log</string>
<string>-e</string>
<string>/Users/admin/Documents/cms/app_error.log</string>
<string>/Users/admin/Documents/cms/app.js</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>root</string>
</dict>
</plist>