mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Fix tail to update status
and retry if file goes away and comes back
This commit is contained in:
parent
2da42c9495
commit
2b50bf38ec
@ -16,6 +16,7 @@ module.exports = function(RED) {
|
||||
|
||||
var fileTail = function() {
|
||||
if (fs.existsSync(node.filename)) {
|
||||
node.status({ });
|
||||
if (node.filetype === "text") {
|
||||
node.tail = new Tail(node.filename,{separator:node.split, flushAtEOF:true});
|
||||
}
|
||||
@ -40,6 +41,7 @@ module.exports = function(RED) {
|
||||
node.tail.on("error", function(err) {
|
||||
node.status({ fill: "red",shape:"ring", text: "node-red:common.status.error" });
|
||||
node.error(err.toString());
|
||||
if (err.code ==="ENOENT") { scheduleRestart(); }
|
||||
});
|
||||
}
|
||||
else {
|
||||
@ -51,6 +53,8 @@ module.exports = function(RED) {
|
||||
var scheduleRestart = function() {
|
||||
node.tout = setTimeout(function() {
|
||||
node.tout = null;
|
||||
if (node.tail) { node.tail.unwatch(); }
|
||||
delete node.tail;
|
||||
fileTail();
|
||||
}, 10000);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-red-node-tail",
|
||||
"version": "0.3.2",
|
||||
"version": "0.4.0",
|
||||
"description": "A node to tail files for Node-RED",
|
||||
"dependencies": {
|
||||
"tail": "^2.2.4"
|
||||
|
Loading…
Reference in New Issue
Block a user