Now that I’m back in the UK, I’ve left a Raspberry Pi2 in Spain monitoring my solar pergola lighting installation as an ESP8266 measures the state of a solar-charged car battery every 15 minutes and reports minimum and maximum voltages daily by email. The unit also controls lighting and while not actually controlling heating, has a test setup which controls a Nextion display. Meanwhile I have a similar setup here in the UK which is actually connected to a Nextion and which will soon be in charge of the household heating.
But something has been bugging me. Regular readers will know that during the last month or so in Spain I had a lot of WIFI issues, pretty much resolved now thanks to the help of you readers – and in that time until I got to the bottom of it all I spent a lot of time improving my ESP8266 boards to the point where I recently took off the last-ditch reset-the-board option as they are working utterly reliably even in the face of rubbish electricity and the WIFI issues.
In a recent development I decided that in the unlikely event of another power cut (turns out not as unlikely as I’d hoped) I’d have Node-red send me an email on startup.
Well, once a day I was getting these, usually around 11am or so. The unit in the UK was slightly different but still generally resetting in the morning. I wrote off to the guys in the Node-Red Google group – they’re really very helpful and they asked me to check using PM2 some things.
Turns out PM2 (process manager) is a lot more powerful than I’d given it credit for. Anyway I sent the guys a copy of my script or rather the part that starts Node-Red and puts it into a service to run after powerup. It goes like this…
pm2 start /usr/bin/node-red -- -v
The first line is probably irrelevant but I tend to do that a lot to avoid surprises. Anyway, I’ve used this from day 1. I’d sent an example log and one of the things in the log was logging of a LED I toggle off once a second in a simple indicator. I did comment that I thought it was a bit daft logging that every second.
One of the guys in the Google group (Dave) asked me why I was using verbose mode for Node-Red and don’t you know – I spotted the “-v” in my script. How that got in there I’ve no idea.
Anyway to cut a long story short, I needed to scrap that service and create a new one without the –v for verbose.
The above line shows list of services running under PM2 – turns out only one – service 0 so…
pm2 delete 0
got rid of if which allowed me to start again…
pm2 start /usr/bin/node-red
So now I have Mode-red running on both machines (since last night) without the verbose logging. I should stress I made absolutely NO other changes. Now bearing in mind that my total work on these Pis is using a couple of percent of processor power typically and maybe 50% of the RAM…. let me throw this at you…
Since restarting the services without verbose mode last night – and bearing in mind it is now 4:30 pm the next day – NEITHER of the Node-Red installations has rebooted yet both have sent in their daily battery state email reports.
There is time yet of course – I may be going off on a complete tangent – but it does seem odd that simply removing verbose logging would stop regular Node-Red reboots!
Update 21:00:00 Wednesday – oh, well, I just had an email from the local Pi to say Node-Red has reset itself. Sigh.