Is there a method to force a write to file of the context data?
I have the settings.js configured for both memory and file storage options of context values. They work properly under normal operations.
My need to force a write/flush is a result of how I am shutting down my rpi from dashboard buttons and NR probably is not being cleanly shutdown by the rpi OS (or maybe my fault). I use a flag value at shutdown to trigger a process only upon first run of the flows on startup, but the setting of my context value several seconds before the OS goes into shutdown is not being saved.
If you installed node red using the script from the docs, and you run node red as a systemd script as recommended then a pi shutdown should do a normal node red stop and flush the data.
So how did you install, how are you running it, and how are you shutting down?
It was also set to auto run upon boot as a service via sudo systemctl enable nodered.service
I have a button in dashboard triggering an exec node which runs terminal command bash -c "exec sudo shutdown -h now"
The dashboard button also triggers a change node that updates my flag variable. The exec node is actually triggered after a 3 second delay node that was intended to give node red a chance to update context to file before executing shutdown.
That should certainly work ok.
Have you confirmed that you are definitely writing your flag to persistent storage, by disconnecting the wire to the exec node, clicking your button, and checking in the context pane that it has been updated in the right context store?
Assuming that is ok, then add a debug node set to output to the console (so that it will go into the log) at the point where you set your context var, then stop node-red and start it again, using node-red-stop node-red-start
Let it startup then click your button so that it shuts down. Then restart it and run sudo journalctl -b -1 -u nodered --no-pager
That should output the log from the previous boot. Find the point at which you restarted node-red and copy/paste the output from there to the end. Post it here using the </> button when pasting it in (put it where it says to paste it). Then we can see if there is anything unnexpected going on.
Thank you for the directions. I tested without the exec wired, my flag is correctly being set.
Looking at the end of the log, I do see some errors around the shutdown, but I am not sure yet what to do with it.
5c577b09]
Mar 10 14:51:45 sewdummy Node-RED[390]: { payload: '0.00', _msgid: 'bf681a346b2eb5e4' }
Mar 10 14:51:45 sewdummy Node-RED[390]: 10 Mar 14:51:45 - [info] [debug:01786f9c5c577b09]
Mar 10 14:51:45 sewdummy Node-RED[390]: { payload: '0.00', _msgid: '17f59d742e61d493' }
Mar 10 14:51:45 sewdummy Node-RED[390]: 10 Mar 14:51:45 - [info] Stopping flows
Mar 10 14:51:45 sewdummy systemd[1]: Stopping Node-RED graphical event wiring tool...
Mar 10 14:51:45 sewdummy Node-RED[390]: 10 Mar 14:51:45 - [info] serial port /dev/ttyACM1 closed
Mar 10 14:51:45 sewdummy Node-RED[390]: 10 Mar 14:51:45 - [info] serial port /dev/ttyACM0 closed
Mar 10 14:51:45 sewdummy Node-RED[390]: 10 Mar 14:51:45 - [info] Stopped flows
Mar 10 14:51:45 sewdummy systemd[1]: nodered.service: Succeeded.
Mar 10 14:51:45 sewdummy systemd[1]: Stopped Node-RED graphical event wiring tool.
Mar 10 14:51:45 sewdummy systemd[1]: nodered.service: Consumed 51.093s CPU time.
Mar 10 14:51:52 sewdummy systemd[1]: Started Node-RED graphical event wiring tool.
Mar 10 14:51:53 sewdummy Node-RED[2288]: 10 Mar 14:51:53 - [info]
Mar 10 14:51:53 sewdummy Node-RED[2288]: Welcome to Node-RED
Mar 10 14:51:53 sewdummy Node-RED[2288]: ===================
Mar 10 14:51:53 sewdummy Node-RED[2288]: 10 Mar 14:51:53 - [info] Node-RED version: v3.0.2
Mar 10 14:51:53 sewdummy Node-RED[2288]: 10 Mar 14:51:53 - [info] Node.js version: v14.21.3
Mar 10 14:51:53 sewdummy Node-RED[2288]: 10 Mar 14:51:53 - [info] Linux 5.15.84-v7l+ arm LE
Mar 10 14:51:54 sewdummy Node-RED[2288]: 10 Mar 14:51:54 - [info] Loading palette nodes
Mar 10 14:51:56 sewdummy Node-RED[2288]: 10 Mar 14:51:56 - [info] Dashboard version 3.3.1 started at /ui
Mar 10 14:51:56 sewdummy Node-RED[2288]: 10 Mar 14:51:56 - [info] Settings file : /home/sewnasty/.node-red/settings.js
Mar 10 14:51:56 sewdummy Node-RED[2288]: 10 Mar 14:51:56 - [info] Context store : 'memoryOnly' [module=memory]
Mar 10 14:51:56 sewdummy Node-RED[2288]: 10 Mar 14:51:56 - [info] Context store : 'file' [module=localfilesystem]
Mar 10 14:51:56 sewdummy Node-RED[2288]: 10 Mar 14:51:56 - [info] User directory : /home/sewnasty/.node-red
Mar 10 14:51:56 sewdummy Node-RED[2288]: 10 Mar 14:51:56 - [warn] Projects disabled : editorTheme.projects.enabled=false
Mar 10 14:51:56 sewdummy Node-RED[2288]: 10 Mar 14:51:56 - [info] Flows file : /home/sewnasty/.node-red/flows.json
Mar 10 14:51:56 sewdummy Node-RED[2288]: 10 Mar 14:51:56 - [info] Server now running at http://127.0.0.1:1880/
Mar 10 14:51:56 sewdummy Node-RED[2288]: 10 Mar 14:51:56 - [warn]
Mar 10 14:51:56 sewdummy Node-RED[2288]: ---------------------------------------------------------------------
Mar 10 14:51:56 sewdummy Node-RED[2288]: Your flow credentials file is encrypted using a system-generated key.
Mar 10 14:51:56 sewdummy Node-RED[2288]: If the system-generated key is lost for any reason, your credentials
Mar 10 14:51:56 sewdummy Node-RED[2288]: file will not be recoverable, you will have to delete it and re-enter
Mar 10 14:51:56 sewdummy Node-RED[2288]: your credentials.
Mar 10 14:51:56 sewdummy Node-RED[2288]: You should set your own key using the 'credentialSecret' option in
Mar 10 14:51:56 sewdummy Node-RED[2288]: your settings file. Node-RED will then re-encrypt your credentials
Mar 10 14:51:56 sewdummy Node-RED[2288]: file using your chosen key the next time you deploy a change.
Mar 10 14:51:56 sewdummy Node-RED[2288]: ---------------------------------------------------------------------
Mar 10 14:51:57 sewdummy Node-RED[2288]: 10 Mar 14:51:57 - [info] Starting flows
Mar 10 14:51:58 sewdummy Node-RED[2288]: 10 Mar 14:51:58 - [info] Started flows
Mar 10 14:51:58 sewdummy Node-RED[2288]: 10 Mar 14:51:58 - [info] [serialconfig:d123421db2f23c55] serial port /dev/ttyACM1 opened at 115200 baud 8N1
Mar 10 14:51:58 sewdummy Node-RED[2288]: 10 Mar 14:51:58 - [info] [serialconfig:42b83bc3db61c1b8] serial port /dev/ttyACM0 opened at 115200 baud 8N1
Mar 10 14:51:58 sewdummy Node-RED[2288]: 10 Mar 14:51:58 - [warn] [ui_svg_graphics:MainAngle] The specified msg.topic is not supported
Mar 10 14:51:58 sewdummy Node-RED[2288]: 10 Mar 14:51:58 - [info] [debug:01786f9c5c577b09]
Mar 10 14:51:58 sewdummy Node-RED[2288]: { payload: '0.00', _msgid: 'c0799aa86591ab2c' }
Mar 10 14:51:58 sewdummy Node-RED[2288]: 10 Mar 14:51:58 - [info] [debug:01786f9c5c577b09]
Mar 10 14:51:58 sewdummy Node-RED[2288]: { payload: '0.00', _msgid: '43a9dae3d2ed229f' }
Mar 10 14:51:58 sewdummy Node-RED[2288]: 10 Mar 14:51:58 - [info] [debug:01786f9c5c577b09]
//*** deleted a bunch of node 2288 payloads here to fit it into the message limit ****//
Mar 10 14:52:41 sewdummy Node-RED[2288]: { payload: '0.00', _msgid: '177c1428f50a80e0' }
Mar 10 14:52:41 sewdummy Node-RED[2288]: 10 Mar 14:52:41 - [info] [debug:01786f9c5c577b09]
Mar 10 14:52:41 sewdummy Node-RED[2288]: { payload: '0.00', _msgid: '112a5134d28955f5' }
Mar 10 14:52:41 sewdummy Node-RED[2288]: 10 Mar 14:52:41 - [info] [debug:01786f9c5c577b09]
Mar 10 14:52:41 sewdummy Node-RED[2288]: { payload: '0.00', _msgid: '0a5b12d850c98e0b' }
Mar 10 14:52:41 sewdummy sudo[2444]: sewnasty : PWD=/home/sewnasty ; USER=root ; COMMAND=/usr/sbin/shutdown -h now
Mar 10 14:52:41 sewdummy Node-RED[2288]: 10 Mar 14:52:41 - [info] [debug:01786f9c5c577b09]
Mar 10 14:52:41 sewdummy Node-RED[2288]: { payload: '0.00', _msgid: '54185e927564e37a' }
Mar 10 14:52:41 sewdummy sudo[2444]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Mar 10 14:52:41 sewdummy Node-RED[2288]: 10 Mar 14:52:41 - [info] [debug:01786f9c5c577b09]
Mar 10 14:52:41 sewdummy Node-RED[2288]: { payload: '0.00', _msgid: 'bf5d798ffb1ba054' }
Mar 10 14:52:41 sewdummy systemd[1]: Stopping Node-RED graphical event wiring tool...
Mar 10 14:52:41 sewdummy sudo[2444]: pam_unix(sudo:session): session closed for user root
Mar 10 14:52:42 sewdummy Node-RED[2288]: 10 Mar 14:52:42 - [info] Stopping flows
Mar 10 14:52:42 sewdummy Node-RED[2288]: 10 Mar 14:52:42 - [red] Uncaught Exception:
Mar 10 14:52:42 sewdummy Node-RED[2288]: 10 Mar 14:52:42 - [error] Error: write EPIPE
Mar 10 14:52:42 sewdummy Node-RED[2288]: at afterWriteDispatched (internal/stream_base_commons.js:156:25)
Mar 10 14:52:42 sewdummy Node-RED[2288]: at writeGeneric (internal/stream_base_commons.js:147:3)
Mar 10 14:52:42 sewdummy Node-RED[2288]: at Socket._writeGeneric (net.js:798:11)
Mar 10 14:52:42 sewdummy Node-RED[2288]: at Socket._write (net.js:810:8)
Mar 10 14:52:42 sewdummy Node-RED[2288]: at writeOrBuffer (internal/streams/writable.js:358:12)
Mar 10 14:52:42 sewdummy Node-RED[2288]: at Socket.Writable.write (internal/streams/writable.js:303:10)
Mar 10 14:52:42 sewdummy Node-RED[2288]: at GPIOInNode.<anonymous> (/home/sewnasty/.node-red/node_modules/node-red-node-pi-gpio/36-rpi-gpio.js:118:34)
Mar 10 14:52:42 sewdummy Node-RED[2288]: at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:329:34
Mar 10 14:52:42 sewdummy Node-RED[2288]: at new Promise (<anonymous>)
Mar 10 14:52:42 sewdummy Node-RED[2288]: at GPIOInNode.Node.close (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:319:17)
Mar 10 14:52:42 sewdummy systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
Mar 10 14:52:42 sewdummy systemd[1]: nodered.service: Failed with result 'exit-code'.
Mar 10 14:52:42 sewdummy systemd[1]: Stopped Node-RED graphical event wiring tool.
Mar 10 14:52:42 sewdummy systemd[1]: nodered.service: Consumed 13.808s CPU time.
That probably explains why it is not writing the context, node-red is crashing before it completes the shutdown.
Do you see that error if you shut down node-red normally, using node-red-stop?
The GPIO In node appears to be crashing. I presume you are using the latest version of that node. I think it needs someone who knows about that node to comment.
I cleared up some of the other debug I didn't realize was writing to log and restarted a couple of times using the stop command. Still has the error. See below.
I am running the most current version of the GPIO node. My system has had node red updated several versions over more than a year. Possibly something got messy in that time. Maybe a fresh reload is in order.
Should I post something on github under the GPIO node, or will someone likely comment here?
-- Journal begins at Wed 2023-02-22 19:37:31 CST, ends at Fri 2023-03-10 17:24:52 CST. --
Mar 10 17:19:52 sewdummy systemd[1]: Started Node-RED graphical event wiring tool.
Mar 10 17:19:58 sewdummy Node-RED[361]: 10 Mar 17:19:58 - [info]
Mar 10 17:19:58 sewdummy Node-RED[361]: Welcome to Node-RED
Mar 10 17:19:58 sewdummy Node-RED[361]: ===================
Mar 10 17:19:59 sewdummy Node-RED[361]: 10 Mar 17:19:58 - [info] Node-RED version: v3.0.2
Mar 10 17:19:59 sewdummy Node-RED[361]: 10 Mar 17:19:58 - [info] Node.js version: v14.21.3
Mar 10 17:19:59 sewdummy Node-RED[361]: 10 Mar 17:19:58 - [info] Linux 5.15.84-v7l+ arm LE
Mar 10 17:20:00 sewdummy Node-RED[361]: 10 Mar 17:20:00 - [info] Loading palette nodes
Mar 10 17:20:18 sewdummy Node-RED[361]: 10 Mar 17:20:18 - [info] Dashboard version 3.3.1 started at /ui
Mar 10 17:20:18 sewdummy Node-RED[361]: 10 Mar 17:20:18 - [info] Settings file : /home/sewnasty/.node-red/settings.js
Mar 10 17:20:18 sewdummy Node-RED[361]: 10 Mar 17:20:18 - [info] Context store : 'memoryOnly' [module=memory]
Mar 10 17:20:18 sewdummy Node-RED[361]: 10 Mar 17:20:18 - [info] Context store : 'file' [module=localfilesystem]
Mar 10 17:20:19 sewdummy Node-RED[361]: 10 Mar 17:20:19 - [info] User directory : /home/sewnasty/.node-red
Mar 10 17:20:19 sewdummy Node-RED[361]: 10 Mar 17:20:19 - [warn] Projects disabled : editorTheme.projects.enabled=false
Mar 10 17:20:19 sewdummy Node-RED[361]: 10 Mar 17:20:19 - [info] Flows file : /home/sewnasty/.node-red/flows.json
Mar 10 17:20:19 sewdummy Node-RED[361]: 10 Mar 17:20:19 - [info] Server now running at http://127.0.0.1:1880/
Mar 10 17:20:19 sewdummy Node-RED[361]: 10 Mar 17:20:19 - [warn]
Mar 10 17:20:19 sewdummy Node-RED[361]: ---------------------------------------------------------------------
Mar 10 17:20:19 sewdummy Node-RED[361]: Your flow credentials file is encrypted using a system-generated key.
Mar 10 17:20:19 sewdummy Node-RED[361]: If the system-generated key is lost for any reason, your credentials
Mar 10 17:20:19 sewdummy Node-RED[361]: file will not be recoverable, you will have to delete it and re-enter
Mar 10 17:20:19 sewdummy Node-RED[361]: your credentials.
Mar 10 17:20:19 sewdummy Node-RED[361]: You should set your own key using the 'credentialSecret' option in
Mar 10 17:20:19 sewdummy Node-RED[361]: your settings file. Node-RED will then re-encrypt your credentials
Mar 10 17:20:19 sewdummy Node-RED[361]: file using your chosen key the next time you deploy a change.
Mar 10 17:20:19 sewdummy Node-RED[361]: ---------------------------------------------------------------------
Mar 10 17:20:19 sewdummy Node-RED[361]: 10 Mar 17:20:19 - [info] Starting flows
Mar 10 17:20:20 sewdummy Node-RED[361]: 10 Mar 17:20:20 - [info] Started flows
Mar 10 17:20:21 sewdummy Node-RED[361]: 10 Mar 17:20:21 - [info] [serialconfig:d123421db2f23c55] serial port /dev/ttyACM1 opened at 115200 baud 8N1
Mar 10 17:20:21 sewdummy Node-RED[361]: 10 Mar 17:20:21 - [info] [serialconfig:42b83bc3db61c1b8] serial port /dev/ttyACM0 opened at 115200 baud 8N1
Mar 10 17:20:21 sewdummy Node-RED[361]: 10 Mar 17:20:21 - [warn] [ui_svg_graphics:MainAngle] The specified msg.topic is not supported
Mar 10 17:23:10 sewdummy Node-RED[361]: 10 Mar 17:23:10 - [info] Stopping flows
Mar 10 17:23:10 sewdummy systemd[1]: Stopping Node-RED graphical event wiring tool...
Mar 10 17:23:10 sewdummy Node-RED[361]: 10 Mar 17:23:10 - [red] Uncaught Exception:
Mar 10 17:23:10 sewdummy Node-RED[361]: 10 Mar 17:23:10 - [error] Error: write EPIPE
Mar 10 17:23:10 sewdummy Node-RED[361]: at afterWriteDispatched (internal/stream_base_commons.js:156:25)
Mar 10 17:23:10 sewdummy Node-RED[361]: at writeGeneric (internal/stream_base_commons.js:147:3)
Mar 10 17:23:10 sewdummy Node-RED[361]: at Socket._writeGeneric (net.js:798:11)
Mar 10 17:23:10 sewdummy Node-RED[361]: at Socket._write (net.js:810:8)
Mar 10 17:23:10 sewdummy Node-RED[361]: at writeOrBuffer (internal/streams/writable.js:358:12)
Mar 10 17:23:10 sewdummy Node-RED[361]: at Socket.Writable.write (internal/streams/writable.js:303:10)
Mar 10 17:23:10 sewdummy Node-RED[361]: at GPIOInNode.<anonymous> (/home/sewnasty/.node-red/node_modules/node-red-node-pi-gpio/36-rpi-gpio.js:118:34)
Mar 10 17:23:10 sewdummy Node-RED[361]: at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:329:34
Mar 10 17:23:10 sewdummy Node-RED[361]: at new Promise (<anonymous>)
Mar 10 17:23:10 sewdummy Node-RED[361]: at GPIOInNode.Node.close (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:319:17)
Mar 10 17:23:10 sewdummy systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
Mar 10 17:23:10 sewdummy systemd[1]: nodered.service: Failed with result 'exit-code'.
Mar 10 17:23:10 sewdummy systemd[1]: Stopped Node-RED graphical event wiring tool.
Mar 10 17:23:10 sewdummy systemd[1]: nodered.service: Consumed 16.149s CPU time.
Well, while I have kept current on node red, I was still running node.js 14.x since the script for updating allows you to maintain the older version. I forced it to update to node.js 16 and now it works without error. Thanks for leading me to the water.
Even though I do not appear to need it right now, back to my original question in case anyone does, is there a method to force a flush write to file?
NOPE. Strike the working part. It worked properly one reboot then back to same issue. I think there may be other issues as I now cannot get the rpi to reboot, only shutdown. Time for a fresh re-load. I will get back to report if it still is broken after that.
Fresh 64bit OS, fresh load of Node-RED, same thing with one reboot seemingly acting proper then the same log error as before. I have a few extra warnings and errors since this is on a bare rpi without any of the external hardware I am using connected.
I am getting inconsistent results. It will work ok a few shutdown cycles then not work again. It is possible something in my work in progress testing of nodes is at fault, but I am not sure I can find it.
-- Journal begins at Mon 2023-02-20 22:19:58 CST, ends at Sun 2023-03-12 23:09:46 CDT. --
Mar 12 23:02:56 armhancer systemd[1]: Started Node-RED graphical event wiring tool.
Mar 12 23:03:01 armhancer Node-RED[391]: 12 Mar 23:03:01 - [info]
Mar 12 23:03:01 armhancer Node-RED[391]: Welcome to Node-RED
Mar 12 23:03:01 armhancer Node-RED[391]: ===================
Mar 12 23:03:02 armhancer Node-RED[391]: 12 Mar 23:03:01 - [info] Node-RED version: v3.0.2
Mar 12 23:03:02 armhancer Node-RED[391]: 12 Mar 23:03:01 - [info] Node.js version: v16.19.1
Mar 12 23:03:02 armhancer Node-RED[391]: 12 Mar 23:03:01 - [info] Linux 5.15.84-v8+ arm64 LE
Mar 12 23:03:06 armhancer Node-RED[391]: 12 Mar 23:03:06 - [info] Loading palette nodes
Mar 12 23:03:10 armhancer Node-RED[391]: 12 Mar 23:03:10 - [info] Dashboard version 3.4.0 started at /ui
Mar 12 23:03:11 armhancer Node-RED[391]: 12 Mar 23:03:11 - [info] Settings file : /home/armhancer/.node-red/settings.js
Mar 12 23:03:11 armhancer Node-RED[391]: 12 Mar 23:03:11 - [info] Context store : 'memoryOnly' [module=memory]
Mar 12 23:03:11 armhancer Node-RED[391]: 12 Mar 23:03:11 - [info] Context store : 'file' [module=localfilesystem]
Mar 12 23:03:11 armhancer Node-RED[391]: 12 Mar 23:03:11 - [info] User directory : /home/armhancer/.node-red
Mar 12 23:03:11 armhancer Node-RED[391]: 12 Mar 23:03:11 - [warn] Projects disabled : editorTheme.projects.enabled=false
Mar 12 23:03:11 armhancer Node-RED[391]: 12 Mar 23:03:11 - [info] Flows file : /home/armhancer/.node-red/flows.json
Mar 12 23:03:11 armhancer Node-RED[391]: 12 Mar 23:03:11 - [warn]
Mar 12 23:03:11 armhancer Node-RED[391]: ---------------------------------------------------------------------
Mar 12 23:03:11 armhancer Node-RED[391]: Your flow credentials file is encrypted using a system-generated key.
Mar 12 23:03:11 armhancer Node-RED[391]: If the system-generated key is lost for any reason, your credentials
Mar 12 23:03:11 armhancer Node-RED[391]: file will not be recoverable, you will have to delete it and re-enter
Mar 12 23:03:11 armhancer Node-RED[391]: your credentials.
Mar 12 23:03:11 armhancer Node-RED[391]: You should set your own key using the 'credentialSecret' option in
Mar 12 23:03:11 armhancer Node-RED[391]: your settings file. Node-RED will then re-encrypt your credentials
Mar 12 23:03:11 armhancer Node-RED[391]: file using your chosen key the next time you deploy a change.
Mar 12 23:03:11 armhancer Node-RED[391]: ---------------------------------------------------------------------
Mar 12 23:03:11 armhancer Node-RED[391]: 12 Mar 23:03:11 - [warn] Encrypted credentials not found
Mar 12 23:03:11 armhancer Node-RED[391]: 12 Mar 23:03:11 - [info] Server now running at http://127.0.0.1:1880/
Mar 12 23:03:11 armhancer Node-RED[391]: 12 Mar 23:03:11 - [info] Starting flows
Mar 12 23:03:12 armhancer Node-RED[391]: 12 Mar 23:03:12 - [info] Started flows
Mar 12 23:03:12 armhancer Node-RED[391]: 12 Mar 23:03:12 - [error] [serialconfig:d123421db2f23c55] serial port /dev/ttyACM1 error: Error: Error: No such file or directory, cannot open /dev/ttyACM1
Mar 12 23:03:12 armhancer Node-RED[391]: 12 Mar 23:03:12 - [error] [serialconfig:42b83bc3db61c1b8] serial port /dev/ttyACM0 error: Error: Error: No such file or directory, cannot open /dev/ttyACM0
Mar 12 23:03:12 armhancer Node-RED[391]: 12 Mar 23:03:12 - [warn] [ui_svg_graphics:MainAngle] The specified msg.topic is not supported
Mar 12 23:06:25 armhancer Node-RED[391]: 12 Mar 23:06:25 - [info] Stopping flows
Mar 12 23:06:26 armhancer Node-RED[391]: 12 Mar 23:06:26 - [info] serial port /dev/ttyACM1 closed
Mar 12 23:06:26 armhancer Node-RED[391]: 12 Mar 23:06:26 - [info] serial port /dev/ttyACM0 closed
Mar 12 23:06:26 armhancer Node-RED[391]: 12 Mar 23:06:26 - [info] Stopped flows
Mar 12 23:06:26 armhancer Node-RED[391]: 12 Mar 23:06:26 - [info] Updated flows
Mar 12 23:06:26 armhancer Node-RED[391]: 12 Mar 23:06:26 - [info] Starting flows
Mar 12 23:06:27 armhancer Node-RED[391]: 12 Mar 23:06:27 - [info] Started flows
Mar 12 23:06:27 armhancer Node-RED[391]: 12 Mar 23:06:27 - [error] [serialconfig:d123421db2f23c55] serial port /dev/ttyACM1 error: Error: Error: No such file or directory, cannot open /dev/ttyACM1
Mar 12 23:06:27 armhancer Node-RED[391]: 12 Mar 23:06:27 - [error] [serialconfig:42b83bc3db61c1b8] serial port /dev/ttyACM0 error: Error: Error: No such file or directory, cannot open /dev/ttyACM0
Mar 12 23:06:37 armhancer Node-RED[391]: 12 Mar 23:06:37 - [info] [debug:to console] true
Mar 12 23:06:37 armhancer Node-RED[391]: 12 Mar 23:06:37 - [error] [play-soundfile:b767d8951e8e5529] Error playing back file /home/sewnasty/soundfx/elephant.wav
Mar 12 23:06:47 armhancer sudo[1838]: armhancer : PWD=/home/armhancer ; USER=root ; COMMAND=/usr/sbin/shutdown -h now
Mar 12 23:06:47 armhancer sudo[1838]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Mar 12 23:06:47 armhancer systemd[1]: Stopping Node-RED graphical event wiring tool...
Mar 12 23:06:47 armhancer sudo[1838]: pam_unix(sudo:session): session closed for user root
Mar 12 23:06:47 armhancer Node-RED[391]: 12 Mar 23:06:47 - [info] Stopping flows
Mar 12 23:06:48 armhancer Node-RED[391]: 12 Mar 23:06:48 - [info] serial port /dev/ttyACM1 closed
Mar 12 23:06:48 armhancer Node-RED[391]: 12 Mar 23:06:48 - [info] serial port /dev/ttyACM0 closed
Mar 12 23:06:48 armhancer Node-RED[391]: 12 Mar 23:06:48 - [red] Uncaught Exception:
Mar 12 23:06:48 armhancer Node-RED[391]: 12 Mar 23:06:48 - [error] Error: write EPIPE
Mar 12 23:06:48 armhancer Node-RED[391]: at afterWriteDispatched (node:internal/stream_base_commons:160:15)
Mar 12 23:06:48 armhancer Node-RED[391]: at writeGeneric (node:internal/stream_base_commons:151:3)
Mar 12 23:06:48 armhancer Node-RED[391]: at Socket._writeGeneric (node:net:905:11)
Mar 12 23:06:48 armhancer Node-RED[391]: at Socket._write (node:net:917:8)
Mar 12 23:06:48 armhancer Node-RED[391]: at writeOrBuffer (node:internal/streams/writable:391:12)
Mar 12 23:06:48 armhancer Node-RED[391]: at _write (node:internal/streams/writable:332:10)
Mar 12 23:06:48 armhancer Node-RED[391]: at Socket.Writable.write (node:internal/streams/writable:336:10)
Mar 12 23:06:48 armhancer Node-RED[391]: at GPIOInNode.<anonymous> (/home/armhancer/.node-red/node_modules/node-red-node-pi-gpio/36-rpi-gpio.js:118:34)
Mar 12 23:06:48 armhancer Node-RED[391]: at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:329:34
Mar 12 23:06:48 armhancer Node-RED[391]: at new Promise (<anonymous>)
Mar 12 23:06:48 armhancer systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
Mar 12 23:06:48 armhancer systemd[1]: nodered.service: Failed with result 'exit-code'.
Mar 12 23:06:48 armhancer systemd[1]: Stopped Node-RED graphical event wiring tool.
Mar 12 23:06:48 armhancer systemd[1]: nodered.service: Consumed 20.239s CPU time.
@MadTooler would you be able to try this?
Edit the file ~/.node-red/node_modules/node-red-node-pi-gpio/36-rpi-gpio.js as suggested by Dave. Restart node-red and try again.
I added the lines you recommended. After over 10 consecutive shutdown cycles of my clean install rpi, context is being stored properly!! My working rpi also saves as intended after a handful or shutdown cycles!
With the lines added, I now see intermittent error messages to the pin usage of GPIO upon shutdown. It still cleanly exits, but I am not sure if those errors are normal or deeper indicators of wherever the specific offender may reside that was causing GPIO to fault. I have several pins in use, but which, if any, or all of the pins showing this type of error seems to vary each time.
Node-RED[390]: 13 Mar 17:24:53 - [error] [rpi-gpio in:myPin] error: -32
HI - great those are the errors being caught... so we are on the right track. As we are actually in the process of shutting down at that point we don't really mind if they do fail, as long as we catch it and exit cleanly.
If you could do another favour.... change the err.errno at the end to just err and see what it reports... (the errno -32 is not very helpful is it
and if that isn't helpful try err.code
Thanks in advance
You are welcome. Glad I could be of some use instead of merely bugging all of you for advice.
I am working on a new CNC motion controller of which Node-RED is a major component. I very much appreciate all of the work you all have poured into the platform and plan to remember it when my project starts to earn its keep.