Create a gist now

Instantly share code, notes, and snippets.

Embed
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>
@natcl

This comment has been minimized.

Show comment
Hide comment
@natcl

natcl 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 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

@natcl

This comment has been minimized.

Show comment
Hide comment
@natcl

natcl 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"
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

This comment has been minimized.

Show comment
Hide comment
@akobelan

akobelan 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.

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

This comment has been minimized.

Show comment
Hide comment
@bkeating

bkeating Sep 8, 2015

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

bkeating commented Sep 8, 2015

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

@cyberreefguru

This comment has been minimized.

Show comment
Hide comment
@cyberreefguru

cyberreefguru Jan 18, 2016

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?

cyberreefguru commented Jan 18, 2016

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?

@WizBangCrash

This comment has been minimized.

Show comment
Hide comment
@WizBangCrash

WizBangCrash Feb 4, 2018

Thanks, @NatCi.
One question: When launchctl launches node-red I get the following error in the node-red.log file:
4 Feb 22:29:36 - [info] Palette editor disabled : npm command not found

When I run node-red from the command line I don't. Do I need to specify anything else in the .plist file? I installed nom using homebrew.

I figured it out minutes after posting my comment :-)
I needed to add the following to my .plist file:

    <key>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>$PATH:/usr/local/bin</string>
    </dict>

Hope this helps others

WizBangCrash commented Feb 4, 2018

Thanks, @NatCi.
One question: When launchctl launches node-red I get the following error in the node-red.log file:
4 Feb 22:29:36 - [info] Palette editor disabled : npm command not found

When I run node-red from the command line I don't. Do I need to specify anything else in the .plist file? I installed nom using homebrew.

I figured it out minutes after posting my comment :-)
I needed to add the following to my .plist file:

    <key>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>$PATH:/usr/local/bin</string>
    </dict>

Hope this helps others

@JJiri

This comment has been minimized.

Show comment
Hide comment
@JJiri

JJiri Jun 14, 2018

Thanks @WizBangCrash,

but where (in file) did you set your instruction?
I set this in org.nodered.plist this:
<key>PATH</key> <string>$PATH:/usr/local/bin</string>

But Pallete still not working...

JJiri commented Jun 14, 2018

Thanks @WizBangCrash,

but where (in file) did you set your instruction?
I set this in org.nodered.plist this:
<key>PATH</key> <string>$PATH:/usr/local/bin</string>

But Pallete still not working...

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