Using pm2 to startup Node-Red

3,236 views
Skip to first unread message

Justin Hope

unread,
Mar 24, 2015, 7:34:57 PM3/24/15
to node...@googlegroups.com
Ok, followed the instructions as per the node-red startup guide but I have an issue that when loaded with pm2, I cant connect to node-red, its like it doesn't exist.  I have looked a 'pm2 monit', and can see it running.⌬ PM2 monitoring :

   ● node-red                            [|||||||||||                   ] 39 %
 [0] [fork_mode]                        [||||||                        ] 17.508 MB

If I manually start node-red from the folder, it runs as intended and I can connect.

Anyone have an idea of why pm2 would be blocking connection to the node-red port selected in settings?  any ideas welcome....

J

************************************************************************************

Think Green!!! Please don't print this e-mail unless you really need to.

************************************************************************************

This e-mail contains proprietary information some or all of which may be legally privileged. It is for the intended recipient only. If an addressing or transmission error has misdirected this e-mail, please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail. Whilst reasonable precautions have been taken to ensure that this message and any attachments are free from viruses or other malicious code, no guarantee is implied or given. The views expressed in this communication may not necessarily be the views held by NXET Trains Limited.


NXET Trains Limited is part of National Express Group. Registered in England No 7897267.  NXET Trains Limited trades as c2c

Registered Office: National Express House, Birmingham Coach Station, Mill Lane, Digbeth, Birmingham, B5 6DD


Nicholas O'Leary

unread,
Mar 24, 2015, 7:39:24 PM3/24/15
to Node-RED Mailing LIst
Hi Justin,

what does `pm2 logs node-red` show? Do you see the normal "Server now running at http:// .... " line?

Nick



--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Justin Hope

unread,
Mar 24, 2015, 7:58:53 PM3/24/15
to node...@googlegroups.com
Evening Nick,

Probably something really simple, but with nothing running :

$ cd /usr/local/lib/node_modules/node-red/
$ pm2 start /usr/local/lib/node_modules/node-red/ --node-args="--max-old-space-size=128" -- -v

[PM2] restartProcessId process id 0
[PM2] Process successfully started
┌────────────────────┬────┬──────┬──────┬─────────┬─────────┬────────┬────────────┬──────────┐
│ App name           │ id │ mode │ pid  │ status  │ restart │ uptime │ memory     │ watching │
├────────────────────┼────┼──────┼──────┼─────────┼─────────┼────────┼────────────┼──────────┤
│ node-red           │ 0  │ fork │ 3401 │ online  │ 115     │ 0s     │ 8.480 MB   │ disabled │
│ pm2-http-interface │ 1  │ fork │ 0    │ stopped │ 0       │ 0      │ 0 B        │ disabled │
└────────────────────┴────┴──────┴──────┴─────────┴─────────┴────────┴────────────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app


Log shows :

2015-03-24 23:55:48: App closed with code: 143
2015-03-24 23:55:48: App name:node-red id:0 exited with code 143
2015-03-24 23:55:48: Process with pid 3443 killed
2015-03-24 23:56:37: Starting execution sequence in -fork mode- for app name:node-red id:0
2015-03-24 23:56:38: App name:node-red id:0 online
2015-03-24 23:56:55: App closed with code: 0
2015-03-24 23:56:55: App name:node-red id:0 exited with code 0
2015-03-24 23:56:55: Starting execution sequence in -fork mode- for app name:node-red id:0
2015-03-24 23:56:55: App name:node-red id:0 online
2015-03-24 23:57:12: App closed with code: 0
2015-03-24 23:57:12: App name:node-red id:0 exited with code 0
2015-03-24 23:57:12: Starting execution sequence in -fork mode- for app name:node-red id:0
2015-03-24 23:57:12: App name:node-red id:0 online
2015-03-24 23:57:29: App closed with code: 0
2015-03-24 23:57:29: App name:node-red id:0 exited with code 0
2015-03-24 23:57:29: Starting execution sequence in -fork mode- for app name:node-red id:0
2015-03-24 23:57:29: App name:node-red id:0 online
2015-03-24 23:57:45: App closed with code: 0
2015-03-24 23:57:45: App name:node-red id:0 exited with code 0
2015-03-24 23:57:46: Starting execution sequence in -fork mode- for app name:node-red id:0
2015-03-24 23:57:46: App name:node-red id:0 online

Looks like the app is closing down soon after starting, circa 15 seconds.

Andrew Lindsay

unread,
Mar 25, 2015, 2:19:52 AM3/25/15
to node...@googlegroups.com
I found I had to do the pm2 commands as root otherwise node-red would not auto start on a Pi.

Cheers

Andrew

Justin Hope

unread,
Mar 25, 2015, 7:59:34 AM3/25/15
to node...@googlegroups.com
Cheers Andy,

Did like you suggest but still no joy.  The only thing that is different is that I altered the default pi account (renamed and change home etc etc) as root.  I doubt this would impact the connectivity side.

Still have the same messages in the logs, start-up with almost immediate shutdown.

Nick,

I did read your message again Nick (full RTFQ) and looked at the logs for the node-red error and out, neither have anything logged within them.

Permissions issue with pm2? 

Regards

J

Justin Hope

unread,
Mar 25, 2015, 8:38:05 AM3/25/15
to node...@googlegroups.com
School boy error it appears....

Path to node-red was incorrect, don't know why I didn't notice it, but all sorted now....

Many thanks for the assistance

Regards

J

Dave C-J

unread,
Mar 25, 2015, 10:24:30 AM3/25/15
to node...@googlegroups.com
Hi Justin
just to clarify... (if not too embarrassing ;-)... where was the path incorrect ? was it something you changed at some point ? or is it something we need to point out in the docs ?
Thanks

Justin Hope

unread,
Mar 25, 2015, 6:25:00 PM3/25/15
to node...@googlegroups.com
Not embarrassing at all, everyday is a school day for me...

Ok, so following the docs online I got to auto starting with pm2  and used the path as indicated :

pm2 start /usr/bin/node-red --node-args="--max-old-space-size=128" -- -v

Path the worked :

$pm2 start /usr/bin/red --node-args="--max-old-space-size=128" -- -v

I had to drop the 'node-' for it to work, after that no issues with running.

Probably my booboo so....

Bernd Loigge

unread,
Jan 23, 2016, 4:32:19 AM1/23/16
to Node-RED
THANK YOU - this cost me days.....

Dave C-J

unread,
Jan 23, 2016, 5:40:15 AM1/23/16
to Node-RED
Actually ... errr...
red.js (which does happen to be executeable -  and would thus pick up wherever node was installed)... - but it's never in /usr/bin and it's not just called red, so why is PM2 ignoring the path but finding it...
for interest sake can your report back what
    which node
and
    which node-red
reveals
If this is on Pi - which distro is this on Wheezy or Jessie ?
Reply all
Reply to author
Forward
0 new messages