Node-Red PM2 Start Problem

925 views
Skip to first unread message

Willem Buitendyk

unread,
Feb 6, 2016, 5:27:35 PM2/6/16
to Node-RED
I'm trying to start node-red on the raspberry pi (jessie) with pm2 from root.  It seems the -node-args argument won't accept userDir as a valid option.

I've tried:

pm2 start /usr/bin/node-red --node-args="--userDir /home/pi/.node-red/" 


which responds with an error of "node: bad option: --userDir" in the error log.  So it looks like the node-args isn't handling the space between userDir and the path


I then tried:  


pm2 start /usr/bin/node-red --node-args=" '--userDir /home/pi/.node-red/' "


which in turn responds with an error of "node: bad option: --userDir /home/pi/.node-red/"



If I try this without pm2 it works just fine. i.e. /usr/bin/node-red --userDir /home/pi/.node-red/


I'm stuck?


Mark Setrem

unread,
Feb 6, 2016, 6:18:01 PM2/6/16
to Node-RED

First a couple of questions...

What is the reason you need to run as root?

Is there any reason you don't want to use the built in systems capability which will automatically start node-red on boot and if it crashes.

If you really need run as root and pm2 , you still should pass the "max-old-space-size" flag to free up memory and the -v flag is useful to diagnose issues on startup so the command you want is:

pm2 start /usr/bin/node-red --node-args="--max-old-space-size=128" -- -v --userDir /home/pi/.nodered

Mark Setrem

unread,
Feb 6, 2016, 6:21:40 PM2/6/16
to Node-RED

or even the built in systemd capability - I'm blaming autocorrect!

Willem Buitendyk

unread,
Feb 6, 2016, 6:48:05 PM2/6/16
to Node-RED
wow that worked.  I guess I didn't understand that userDir is not a node-argument but a system argument.  The funny thing is I got so possessed with trying to make this work that I can't even remember why I needed to run it as root.  

As for PM2 - I was simply going with the node-red online manual under the running section.  I presumed PM2 was better suited to the node-red server and pick up the pieces after a crash.  Are you saying that systemd will handle this?  

Thanks for your help.  

Mark Setrem

unread,
Feb 6, 2016, 7:05:55 PM2/6/16
to Node-RED
If you look at the raspberry pi page http://nodered.org/docs/hardware/raspberrypi.html

Theres a section on "Adding Autostart capability using SystemD" so yes (theres some scripts you need to download)












Willem Buitendyk

unread,
Feb 6, 2016, 9:49:52 PM2/6/16
to Node-RED
Indeed.  I was going by this page http://nodered.org/docs/getting-started/running.html which towards the bottom talks about PM2 and has little subtexts regarding using the PI.  Thank you for the link.  I'd prefer to use systemd and services.  

Dave C-J

unread,
Feb 7, 2016, 4:55:35 AM2/7/16
to node...@googlegroups.com
Willem,

I'll try and tidy up those docs :-)
Since November the default Raspbian Jessie SD card image contained Node-RED and some script to help autostart. However the initial version used init.d style - since then version 0.12.4 has been released to the repo so a  sudo apt-get update && sudo apt-get install nodered should pull in that version and that already includes all the necessary systemd scripts - If you type node-red-start on that version it will tell you what you need to do to enable it...  

Reply all
Reply to author
Forward
0 new messages