Anyone running node-red under forever or some other node running package?

838 views
Skip to first unread message

chris mobberley

unread,
Nov 12, 2014, 7:30:22 AM11/12/14
to node...@googlegroups.com
Just installed ghost blog and they recommend using forever to keep ghost running.


I was wondering if anyone is using forever to manage node-red? Are there any specific parameters you are passing in e.g. the adjustment to the max-size

Has anyone experiences of other packages that can do this? I have been using the trust init and daemon scripts so far.

Lawrence Griffiths

unread,
Nov 12, 2014, 7:49:20 AM11/12/14
to node...@googlegroups.com
Chris yes I am and I've seen others on the forum who have.
I use an init.d script it works well on my RPI.  

I pass in the max size 
sudo -i -u $USER $NODE start -c "node --max-old-space-size=192"  $SERVER_JS_FILE

Can share full script but I'm not hot on Linux/Bash etc.
So someone more proficient might be a better bet.

Lawrence

Claudiu O

unread,
Nov 13, 2014, 10:35:54 AM11/13/14
to node...@googlegroups.com
I installed node-red as described here http://l0l.org.uk/2013/11/setting-pi-bare-os-work-node-red-controller/ including the init.d script (with some small changes) and using monit as recommended on that page.

Nicholas O'Leary

unread,
Nov 13, 2014, 6:05:09 PM11/13/14
to node...@googlegroups.com
I use forever on my web host to keep node-red ticking. I haven't really spent any time investigating the various options it provides. I just run:
    forever start red.js --settings mysettings.js -v

I'm sure there's more I could be doing, but it seems reliable to me.

Nick



On Thu Nov 13 2014 at 15:35:55 Claudiu O <clau...@gmail.com> wrote:
I installed node-red as described here http://l0l.org.uk/2013/11/setting-pi-bare-os-work-node-red-controller/ including the init.d script (with some small changes) and using monit as recommended on that page.

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

Brian Bagdasarian

unread,
Nov 14, 2014, 1:41:30 AM11/14/14
to node...@googlegroups.com
I run it embedded in Sails

Lawrence Griffiths

unread,
Nov 14, 2014, 4:08:23 AM11/14/14
to node...@googlegroups.com
Nick could you share your mysetting.js this seems a much tidier way of doing things.

Lawrence

Christopher Mobberley

unread,
Nov 14, 2014, 4:21:56 AM11/14/14
to node...@googlegroups.com
I'm running with forever now..seems easier and I've added a cron job to start it up from boot. There are a few boot versions for forever available but unsure on which was easiest to pick

--
http://nodered.org
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/uJKUZOzFsOU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

Nicholas O'Leary

unread,
Nov 14, 2014, 4:43:29 AM11/14/14
to node...@googlegroups.com
Lawrence, there's nothing special in mysettings.js - just some environment specific things for my web host, such as port to listen to etc.

Nick

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.

Claudiu O

unread,
Nov 14, 2014, 11:54:55 AM11/14/14
to node...@googlegroups.com
Thanks, Nick for posting the command and chris for mentioning using cron. I have no experience with forever or cron but it sounds pretty easy. This way I can replace the init.d script because I found an issue with rpi-gpio nodes not working when node-red is started at boot time with the init.d script. Thanks to all the posters for ideas.

   claudiu

Lawrence Griffiths

unread,
Nov 14, 2014, 12:41:54 PM11/14/14
to node...@googlegroups.com
claudiu 
>>This way I can replace the init.d script because I found an issue with rpi-gpio nodes not working when node-red is started at boot time with the init.d script. 

Thanks for this, as I've just encountered this problem for the first time.
Strange no error on node 0.10.26 but get it on 0.10.28
With both RPI running 0.9.1 git

Lawrence 

Antoine Aflalo

unread,
Nov 14, 2014, 4:15:18 PM11/14/14
to node...@googlegroups.com
Does the GPIO have an init.d script ?
Because I can modify the init.d script to make it start after the gpio
is initialized.

In case of, Debian will move to systemd as service manager (as process
manager in fact). It's easy to create a service unit that will restart
on failure.

2014-11-14 19:41 UTC+02:00, Lawrence Griffiths
<lawrence....@googlemail.com>:
> --
> 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.
>


--
Antoine Aflalo

Claudiu O

unread,
Nov 14, 2014, 6:30:51 PM11/14/14
to node...@googlegroups.com
That's exactly what I thought, that maybe somehow I need to make node-red start after gpio but being so green at linux I opted for a node-red restart for now.

Claudiu O

unread,
Dec 22, 2014, 10:13:21 AM12/22/14
to node...@googlegroups.com
I switched to forever and everything looks great. One thing I don't know how to do: how do I see the node-red logs? The old init.d script was saving the logs in '/var/log/node-red.log' but this is not the case anymore. I searched for a node-red.log or forever.log but couldn't find it anywhere. I assume this is more like a forever question than node-red but if anyone has any idea, I'd really appreciate an answer. Thank you!

Christopher Mobberley

unread,
Dec 22, 2014, 10:22:03 AM12/22/14
to node...@googlegroups.com

As per the npm page it will be one of the following ways I expect:

[Long Running Process]
    The forever process will continue to run outputting log messages to the console.
    ex. forever -o out.log -e err.log my-script.js

  [Daemon]
    The forever process will run as a daemon which will make the target process start
    in the background. This is extremely useful for remote starting simple node.js scripts
    without using nohup. It is recommended to run start with -o -l, & -e.
    ex. forever start -l forever.log -o out.log -e err.log my-daemon.js
        forever stop my-daemon.js
There are several examples designed to test the


--
http://nodered.org
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/uJKUZOzFsOU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

Claudiu O

unread,
Dec 22, 2014, 10:32:49 AM12/22/14
to node...@googlegroups.com
Thanks a lot, Chris, this helps tons. I start my node-red using cron at boot time (as you suggested, if I remember well) as @reboot sudo forever start <path_to_nodered>/red.js --max-old-space-size=256 -v &, I will add the -o, -l and -e args to the command. Thanks again!

chris mobberley

unread,
Dec 26, 2014, 7:50:09 AM12/26/14
to node...@googlegroups.com
Did you find any settings working for you? At the moment I am still on the daemon script but I am using forever on other Node apps at the moment but would be nice to switch node-red over now.

Nicholas Humfrey

unread,
Dec 26, 2014, 1:11:01 PM12/26/14
to node...@googlegroups.com
Hello,

I am using daemontools to keep Node-RED running on my machine. It also
performs automatic restarts if Node-RED dies. These are the two shell
scripts that I use:

/service/nodered/run:

#!/bin/sh

exec 2>&1
cd /usr/local/nodered
exec nodejs red.js -v --settings /etc/nodered/settings.js



/service/nodered/log/run:

#!/bin/sh
exec multilog ./main


The log script writes anything written to STDOUT or STDERR to a rotated
log file.

I have Node-RED source code installed the directory /usr/local/nodered
and I keep my settings and flow files separately under /etc/nodered.
This allows me to separate out the files that I created and modified
from the main codebase.


Daemontools is available here:
http://cr.yp.to/daemontools.html

Or installable as a package on most Unix operating systems.


nick.
> --
> http://nodered.org [1]
> ---
> 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 [2].
> For more options, visit https://groups.google.com/d/optout [3].

Claudiu O

unread,
Dec 28, 2014, 1:13:49 AM12/28/14
to node...@googlegroups.com
I ended up going with forever start -o /home/pi/node-red/nodered_out.log -e /home/pi/node-red/nodered_err.log <path_to_nodered>/red.js -v and it seems to work great. The err log seems to be empty all the time but I left it in there just in case.

chris mobberley

unread,
Jan 1, 2015, 4:20:25 PM1/1/15
to node...@googlegroups.com
I was being a bit slow and forgot that forever auto logs too. You can usually see the info if you do "forever list" and it will state a logfile location e.g.:

info:    Forever restarted process(es):
data:        uid  command             script forever pid   id logfile                        uptime       
data:    [0] OkKh /usr/local/bin/node app.js 21791   21798    /home/munkee/.forever/OkKh.log 0:0:9:41.508 

As you can see mine is under .forever/OkKh.log

Ηλίας Καρακουλάκης

unread,
Jan 13, 2015, 10:17:49 AM1/13/15
to node...@googlegroups.com
I also use monit to keep an eye on the node.js process, should it fail its automatically restarted. NR looking very stable, only a handful of unexpected crashes in the 4 months or so I'm using it 24/7
Reply all
Reply to author
Forward
0 new messages