failure to restart flows after a full deploy

383 views
Skip to first unread message

Tim Teague

unread,
Jun 25, 2016, 2:10:07 PM6/25/16
to Node-RED
I have been experiencing a problem for the last few weeks with the deploy function. I always use full deploy and nodered is running as a systemd service. When I click deploy, I can see in the log that the flows have been stopped and then nodered seems to be hung as there is no more log activity and the ui in the browser doesn't show the deployed successfully message. I use "systemctl restart nodered" to get things going again. It's not a show stopper as the restart gets everything running with the changes included. There are no unusual errors during the startup or when running. The editor doesn't show any errors for any of the functions and I have no idea what I could change to get back to normal. The size of the flows file is nearly 120KB (with "pretty" enabled).

A deploy and restart looks like this in the log file:

25 Jun 10:10:44 - [info] Stopping flows
25 Jun 10:10:44 - [info] [tcp in:ba3ac45a.45c538] stopped listening on port
Welcome to Node-RED
===================
25 Jun 10:10:49 - [info] Node-RED version: v0.13.4
25 Jun 10:10:50 - [info] Node.js  version: v4.4.5
25 Jun 10:10:50 - [info] Linux 4.4.12-bone-rt-r11 arm LE
25 Jun 10:10:50 - [info] Loading palette nodes
{ MODE: { MODE_0: 0, MODE_1: 1, MODE_2: 2, MODE_3: 3 },
CS: { none: 64, high: 4, low: 0 },
ORDER: { msb: false, lsb: true },
Spi: [Function] }
25 Jun 10:10:58 - [info] Settings file  : /home/cd5/server/settings.js
25 Jun 10:10:58 - [info] User directory : /home/cd5/server
25 Jun 10:10:58 - [info] Flows file : /home/cd5/server/flows_cd5.json
25 Jun 10:10:58 - [info] Server now running at http://127.0.0.1:80/admin/
25 Jun 10:10:59 - [info] Starting flows
25 Jun 10:11:00 - [info] [tcp out:send shed msgs] connecting to 127.0.0.1:5678
25 Jun 10:11:01 - [info] Started flows


The package.json file doesn't include much:

  "dependencies": {
    "mime": ">=1.2",
    "onoff": ">=1.0.2",
    "spi": ">=0.2.0"
  },

I suspect that you will want a copy of my code, but that would be problematical on a couple of levels. First, I would need my employer to agree to release it, and second, it is very hardware specific.

Please let me know if there is anything I can do to help

Nicholas O'Leary

unread,
Jun 25, 2016, 4:23:00 PM6/25/16
to Node-RED Mailing List
This will be caused by a node that is hanging when it is being closed.

Our _next_ release will have some tracing code in there to help identify what would be causing this sort of thing... but that won't help you today.

I can point you to a couple places to stick some debug in that will identify what node is hanging - we can then work back from there.

First, add:
    console.log("closing",this.id,this.type);

then add
   console.log("closed", node.id, node.type);

Then, when you hit deploy, you will be able to spot what node prints out 'closing' but not 'closed'.

LIke I said... we'll be adding some tracing here to help in the future.

Nick


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
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.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Tim Teague

unread,
Jun 26, 2016, 11:47:54 AM6/26/16
to Node-RED
Thanks Nick, that was the clue I needed. Of course it was in a custom node that I had written to wrap the npm module "spi".

However, it brought to light a problem with my handling of context.global from a custom node. The following three lines
        console.log('myContext:', myContext);
        console.log('myContext.global:', util.inspect(myContext.global));
        gpios = myContext.global.get('gpios');
produce this output:
myContext: function () {
if (!this._context) {
this._context = context.get(this._alias||this.id,this.z);
}
return this._context;
}
myContext.global: undefined
26 Jun 08:36:26 - [error] [spiSender:14217adb.ebde85] TypeError: Cannot read property 'get' of undefined

My guess is that I just broke this as it was working until I started mucking around in this code :-)

Nicholas O'Leary

unread,
Jun 26, 2016, 6:55:08 PM6/26/16
to Node-RED Mailing List
When accessing context inside a node implementation and not the Function node, there's a subtly difference in syntax: 'context' is a function you have to call to get ahold of your context object:

var globalContext = this.context().global;
globalContext.set("foo","bar");  




Tim Teague

unread,
Jun 26, 2016, 11:52:39 PM6/26/16
to Node-RED
Yes, I found that, but it doesn't solve the problem. I'm trying to create and populate an object and put it in global from within a custom node and then access it from a function node. I have put together a simplified test case - maybe from that you can point me in the right direction.

Just click the inject node and it should dump what it sees to the debug panel. 

The test flow is: [{"id":"354fd111.cab02e","type":"inject","z":"784c8074.87b38","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":120,"y":200,"wires":[["b89849bf.4767b8"]]},{"id":"b89849bf.4767b8","type":"function","z":"784c8074.87b38","name":"Dump testObj","func":"var testObj = global.get('testObj');\nnode.warn('test object:', util.inspect(testObj));\nif (testObj === undefined) {\n    node.warn('test object undefined');\n}\nnode.warn('test object type:', typeof testObj);\nnode.warn('test object toString:', testObj.toString());\nreturn null;","outputs":1,"noerr":0,"x":350,"y":200,"wires":[[]]}]

The html is:
<script type="text/javascript">
    RED.nodes.registerType('test',{
        category: 'function',
        color: '#a6bbcf',
        defaults: {
            name: {value:""}
        },
        inputs:1,
        outputs:1,
        icon: "file.png",
        label: function() {
            return this.name||"test";
        }
    });
</script>

<script type="text/x-red" data-template-name="test">
    <div class="form-row">
        <label for="node-input-name"><i class="icon-tag"></i> Name</label>
        <input type="text" id="node-input-name" placeholder="Name">
    </div>
</script>

<script type="text/x-red" data-help-name="test">
    <p>This node sets the Content-Type header to match the msg.filename</p>
</script>

and the js is:
module.exports = function(RED) {
    function testNode(config) {
        RED.nodes.createNode(this,config);
        var node = this;
        var testObj = {};
        testObj.a = 'a';
        testObj.b = 'b';
        this.context.global.set('testObj', testObj);
        this.on('input', function(msg) {
            msg.payload = 'test';
        });
    }
    RED.nodes.registerType("test", testNode);
}

Nicholas O'Leary

unread,
Jun 27, 2016, 5:15:22 AM6/27/16
to Node-RED Mailing List
Tim,

in that code you have the line:

    this.context.global.set('testObj', testObj);

as per my previous reply, that should be:

    this.context().global.set('testObj', testObj);

Nick

Tim Teague

unread,
Jun 27, 2016, 5:26:45 PM6/27/16
to Node-RED
I think my fingers were on autopilot. Thanks for your patience. That got me over the hurdle.
Reply all
Reply to author
Forward
0 new messages