node-red-nodes
node-red-nodes copied to clipboard
node-red-node-tail causes node-red termination after size check for /var/log/messages error: ENOENT: no such file or directory, stat '/var/log/messages'
Which node are you reporting an issue on?
node-red-node-tail is used in this flow for displaying error messages in a node-red-dashboard
[{"id":"e84c1031.b43f2","type":"tail","z":"d14800ce.426d4","name":"","filetype":"text","split":"true","filename":"/var/log/messages","inputs":0,"x":130,"y":1140,"wires":[["15fbcaac.5e0b35"]]},{"id":"15fbcaac.5e0b35","type":"switch","z":"d14800ce.426d4","name":"Filter Errors","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Error","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":330,"y":1140,"wires":[["34b6985e.3703f","62b4aeaa.115f78"]]},{"id":"34b6985e.3703f","type":"counter","z":"d14800ce.426d4","name":"Count Errors","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":2,"x":510,"y":1140,"wires":[["ec3d71c8.81c3c8","990394e1.b136a"],["fdf03a43.c8ac2","59598d5a.a91a9c"]]},{"id":"ec3d71c8.81c3c8","type":"ui_gauge","z":"d14800ce.426d4","name":"CCU Fehler","group":"b2a5740.e3c2f1","order":1,"width":6,"height":4,"gtype":"gage","title":"Anzahl","label":"Fehler","format":"{{value}}","min":0,"max":"500","colors":["#00b500","#e6e600","#ca3838"],"seg1":"125","seg2":"250","x":690,"y":1080,"wires":[]},{"id":"fdf03a43.c8ac2","type":"function","z":"d14800ce.426d4","name":"Rotate Entries","func":"var dashboardLog = context.get('dashboardLog')|| [];\n \ndashboardLog.push(msg);\nif (dashboardLog.length > 20) {\n // Delete oldest message if > 20\n dashboardLog.shift();\n dashboardLog.length = 20;\n} \n\nif (msg.resetlog) {\n dashboardLog = [];\n}\n \n// store the value back\ncontext.set('dashboardLog',dashboardLog);\n \n// make it part of the outgoing msg object\nmsg = {};\nmsg.payload = dashboardLog;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":1200,"wires":[["f3be4f6c.225958"]]},{"id":"59598d5a.a91a9c","type":"join","z":"d14800ce.426d4","name":"Prepare Message","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\r\\n","joinerType":"str","accumulate":false,"timeout":"","count":"5","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":710,"y":1140,"wires":[[]]},{"id":"f3be4f6c.225958","type":"ui_template","z":"d14800ce.426d4","group":"97aaa7e1.c96128","name":"Error Dashboard Log","order":1,"width":12,"height":7,"format":"<ul>\n <li ng-repeat=\"x in msg.payload\">\n <p style=\"color:red\">{{x.topic}}</p>\n <ul>\n <li><p style=\"font-size:11px\">{{x.payload}}</p></li>\n </ul>\n </li>\n</ul>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":940,"y":1200,"wires":[[]]},{"id":"9688061b.b2dc48","type":"ui_button","z":"d14800ce.426d4","name":"Reset Error Count","group":"b2a5740.e3c2f1","order":5,"width":0,"height":0,"passthru":false,"label":"Zurücksetzen","tooltip":"","color":"","bgcolor":"","icon":"mi-clear","payload":"true","payloadType":"bool","topic":"","x":130,"y":1080,"wires":[["229fc580.c38dc2"]]},{"id":"229fc580.c38dc2","type":"change","z":"d14800ce.426d4","name":"Set Reset Message","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"Reset Error Count","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":1080,"wires":[["34b6985e.3703f"]]},{"id":"83893482.d56ca8","type":"ui_button","z":"d14800ce.426d4","name":"Clear DashLog","group":"97aaa7e1.c96128","order":2,"width":0,"height":0,"passthru":false,"label":"Protokoll leeren","tooltip":"Anzeige der letzten 20 gespeicherten Fehler löschen","color":"","bgcolor":"","icon":"mi-delete_sweep","payload":"true","payloadType":"bool","topic":"","x":120,"y":1200,"wires":[["ad9da38f.553c98"]]},{"id":"ad9da38f.553c98","type":"change","z":"d14800ce.426d4","name":"Set Reset Message","rules":[{"t":"set","p":"resetlog","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":1200,"wires":[["fdf03a43.c8ac2"]]},{"id":"990394e1.b136a","type":"ui_text","z":"d14800ce.426d4","group":"3917802.e83608","order":2,"width":0,"height":0,"name":"","label":"CCU Fehler:","format":"{{value}}","layout":"row-left","x":690,"y":1040,"wires":[]},{"id":"62b4aeaa.115f78","type":"debug","z":"d14800ce.426d4","name":"Filtered Errors","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":700,"y":1260,"wires":[]},{"id":"b2a5740.e3c2f1","type":"ui_group","name":"Fehler","tab":"a46e92f.58191f","order":6,"disp":true,"width":"6","collapse":false},{"id":"97aaa7e1.c96128","type":"ui_group","name":"Fehlermeldungen","tab":"a46e92f.58191f","order":7,"disp":true,"width":"12","collapse":false},{"id":"3917802.e83608","type":"ui_group","name":"Ereignisse","tab":"4e9b13b2.12840c","order":6,"disp":true,"width":"6","collapse":false},{"id":"a46e92f.58191f","type":"ui_tab","name":"System","icon":"settings","order":10,"disabled":false,"hidden":false},{"id":"4e9b13b2.12840c","type":"ui_tab","name":"Home","icon":"home","order":1}]
What are the steps to reproduce?
There seems not to be an easy way to reproduce. I experience this problem several times with no visible cause. The only guess I have could be the daily rotation of the /var/log/messages file executed by a cron job. But this happens at a different time (each Midnight) as the crash of the node-red daemon process. May be a simultaneous access by a second process, since the relevant file is used for logging messages from the system running node-red.
What happens?
node-red-node-tail log a node-red error, after that the node-red daemon terminates:
Apr 9 01:56:12 {{HOSTNAME}} node-red[7898]: [tail:e84c1031.b43f2] size check for /var/log/messages failed: Error: ENOENT: no such file or directory, stat '/var/log/messages'
Apr 9 01:56:12 {{HOSTNAME}} node-red: 9 Apr 01:56:12 - [red] Uncaught Exception:
Apr 9 01:56:12 {{HOSTNAME}} node-red: 9 Apr 01:56:12 - Error: ENOENT: no such file or directory, stat '/var/log/messages'
Apr 9 01:56:12 {{HOSTNAME}} node-red: at Object.statSync (fs.js:1086:3)
Apr 9 01:56:12 {{HOSTNAME}} node-red: at Tail.latestPosition (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:74:23)
Apr 9 01:56:12 {{HOSTNAME}} node-red: at Tail.change (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:118:22)
Apr 9 01:56:12 {{HOSTNAME}} node-red: at Tail.watchEvent (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:183:18)
Apr 9 01:56:12 {{HOSTNAME}} node-red: at FSWatcher.<anonymous> (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:143:101)
Apr 9 01:56:12 {{HOSTNAME}} node-red: at FSWatcher.emit (events.js:315:20)
Apr 9 01:56:12 {{HOSTNAME}} node-red: at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:186:12)
Apr 9 01:56:12 {{HOSTNAME}} node-red: Node-RED exited with non-zero exit status 1
...
Apr 9 12:15:48 {{HOSTNAME}} node-red[24971]: [tail:e84c1031.b43f2] size check for /var/log/messages failed: Error: ENOENT: no such file or directory, stat '/var/log/messages'
Apr 9 12:15:49 {{HOSTNAME}} node-red: 9 Apr 12:15:49 - [red] Uncaught Exception:
Apr 9 12:15:49 {{HOSTNAME}} node-red: 9 Apr 12:15:49 - Error: ENOENT: no such file or directory, stat '/var/log/messages'
Apr 9 12:15:49 {{HOSTNAME}} node-red: at Object.statSync (fs.js:1086:3)
Apr 9 12:15:49 {{HOSTNAME}} node-red: at Tail.latestPosition (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:74:23)
Apr 9 12:15:49 {{HOSTNAME}} node-red: at Tail.change (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:118:22)
Apr 9 12:15:49 {{HOSTNAME}} node-red: at Tail.watchEvent (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:183:18)
Apr 9 12:15:49 {{HOSTNAME}} node-red: at FSWatcher.<anonymous> (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:143:101)
Apr 9 12:15:49 {{HOSTNAME}} node-red: at FSWatcher.emit (events.js:315:20)
Apr 9 12:15:49 {{HOSTNAME}} node-red: at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:186:12)
Apr 9 12:15:49 {{HOSTNAME}} node-red: Node-RED exited with non-zero exit status 1
What do you expect to happen?
Even if the log file is not accessible by node-red-node-tail, the error should be caught and not causing termination of node red daemon. There is no indication of deletion of the message log file, neither by a process nor manually while node-red is running.
Please tell us about your environment:
- [X] Node-RED version: 1.2.9
- [X] node.js version: 14.16.0
- [X] npm version: 5.6.0
- [X] Platform/OS: Linux 4.14.34 arm LE
- [X] Browser: Safari, Chrome, Firefox on macOS 11.2.3
I notice the author of the tail.js library we use has pushed some error handling changes in the last couple of days. I'll bump out package to see if that helps pick them up. please try version 0.3.1 and report back. thanks
Have upgraded to this version:
But the problem is still there:
Apr 13 11:55:30 {{HOSTNAME}} node-red[16624]: [tail:e84c1031.b43f2] size check for /var/log/messages failed: Error: ENOENT: no such file or directory, stat '/var/log/messages'
Apr 13 11:55:30 {{HOSTNAME}} node-red: 13 Apr 11:55:30 - [red] Uncaught Exception:
Apr 13 11:55:30 {{HOSTNAME}} node-red: 13 Apr 11:55:30 - Error: ENOENT: no such file or directory, stat '/var/log/messages'
Apr 13 11:55:30 {{HOSTNAME}} node-red: at Object.statSync (fs.js:1086:3)
Apr 13 11:55:30 {{HOSTNAME}} node-red: at Tail.latestPosition (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:81:23)
Apr 13 11:55:30 {{HOSTNAME}} node-red: at Tail.change (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:125:22)
Apr 13 11:55:30 {{HOSTNAME}} node-red: at Tail.watchEvent (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:188:18)
Apr 13 11:55:30 {{HOSTNAME}} node-red: at FSWatcher.<anonymous> (/usr/local/addons/redmatic/var/node_modules/node-red-node-tail/node_modules/tail/lib/tail.js:149:97)
Apr 13 11:55:30 {{HOSTNAME}} node-red: at FSWatcher.emit (events.js:315:20)
Apr 13 11:55:30 {{HOSTNAME}} node-red: at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:186:12)
Apr 13 11:55:31 {{HOSTNAME}} node-red: Node-RED exited with non-zero exit status 1
Apr 13 11:55:31 {{HOSTNAME}} redmatic: Restarting Node-RED (1/2)
Have the tail-node disconnected a five days ago and haven't seen this error again.
I also send the log messages accessed by the tail-node in the mentioned log to a separately running Raspi (syslog-server) and will tap there times for verification of the syslog-server target log with the tail-node. Let's see if something like that happens here too.
Based on the feedback of others, the issues seems really related to be causes by tail-node.
Running the tail-node downgraded to version0.1.1 since a couple of weeks now in the above mentioned scenario/node-red-flow. The problem has never happened so far.
Any idea of the difference between 0.1.1 and 0.3.1 related to this issue?