Running automatically at user login:
1. save this to ~/Library/LaunchAgents/com.github.nfarina.homebridge.plist - remembering of course to change to your username and paths
2. run in Terminal 'launchctl load ~/Library/LaunchAgents/com.github.nfarina.homebridge.plist'
3. to run now, run in Terminal 'launchctl start com.github.nfarina.homebridge'. Use 'stop' to make it stop later if you want.
Next time you log in your user, it will automatically launch this (once). Once you're comfortable with it working properly, then you can delete the lines about stdout and stderr.
<?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>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:$PATH</string>
<key>NODE_PATH</key>
<string>/Users/dbrown/homebridge/node_modules</string>
</dict>
<key>Label</key>
<string>com.github.nfarina.homebridge</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/node</string>
<string>app.js</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/Users/dbrown/homebridge</string>
<key>StandardErrorPath</key>
<string>/Users/dbrown/homebridge/stderr.txt</string>
<key>StandardOutPath</key>
<string>/Users/dbrown/homebridge/stdout.txt</string>
</dict>
</plist>
Also note that I compiled mine with NPM_CONFIG_PREFIX set so that maybe the whole thing might be in the same directory (I'm new at the node.js thing), so I included this in my EnvironmentVariables as well:
<key>NPM_CONFIG_PREFIX</key>
<string>/Users/dbrown/homebridge</string>