Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Node-Red launchd script
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.nodered.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/node</string>
<string>/usr/local/bin/node-red</string>
<string>-v</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/Users/YOURUSER/.node-red/node-red.log</string>
<key>WorkingDirectory</key>
<string>/Users/YOURUSER/.node-red</string>
</dict>
</plist>
Owner
natcl commented Feb 28, 2015

This is a Launchd script for Node-Red so that it launches on stratup and restarts if it crashes.
This script assumes you have installed Node-Red using the command sudo npm install -g node-red
Make sure to change /Users/YOURUSER to your own user's home directory path.

You will need to place this script in /Users/YOURUSER/LaunchAgents and then run launchctl load -w org.nodered.plist from that directory.

To stop the daemon you can run launchctl unload org.nodered.plist

Owner
natcl commented Mar 1, 2015

Here's an alias you can add to your .bashrc or .bash_profile file to quickly restart node-red:

alias restartnode="launchctl unload ~/Library/LaunchAgents/org.node-red.plist ; launchctl load -w ~/Library/LaunchAgents/org.node-red.plist"
akobelan commented Sep 7, 2015

Nice work. There is an inconsistency in the naming of your plist file. Either name the plist file org.node-red.plist or org.nodered.plist. The alias you provide will not work otherwise. Newcomers will likely not figure this out.

Thanks for helping out the "other" platform.

bkeating commented Sep 8, 2015

Thanks, @natcl. Very useful. Saved me time.

The first comment says the script should go into "/Users/YOURUSER/LaunchAgents" but it appears it should really go into "/Users/YOURUSER/Library/LaunchAgents" instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment