Mac OSX: NodeJS Automatic Start after Reboot

For those who might not be aware of how to make services such as the HubConnect Proxy run automatically on a Macintosh:

  1. Create a file "HubConnectProxy.plist":
    nano ~/library/launchagents/HubConnectProxy.plist

  2. Copy the text below into the editor (change the line where "csteele" appears to match where you installed the proxy code)

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" ""> <plist version="1.0"> <dict> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> <key>Label</key> <string>HubConnectProxy</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/node</string> <string>/users/csteele/.HubConnectProxy/proxy.js</string> </array> <key>StandardOutPath</key> <string>/var/log/hcproxy.log</string> <key>StandardErrorPath</key> <string>/var/log/hcproxy.log</string> <key>EnvironmentVariables</key> <dict> <key>PATH</key> <string>/usr/local/bin/:$PATH</string> </dict> </dict> </plist>
  1. Exit nano with the following commands
    ctrl-X, Y, return

  2. Run the following commands
    launchctl unload ~/library/launchagents/HubConnectProxy.plist
    launchctl load ~/library/launchagents/HubConnectProxy.plist

The hcproxy will start on boot, and it will automatically be restarted if it fails.

All of the output is automatically logged to /var/log/daemon.log - you can watch it with this command:
tail -f /var/log/hcproxy.log