Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daemon node #660

Open
5 tasks
26tajeen opened this issue Jun 24, 2020 · 7 comments
Open
5 tasks

Daemon node #660

26tajeen opened this issue Jun 24, 2020 · 7 comments

Comments

@26tajeen
Copy link

Daemon Node

The daemon node does not perform as reliably and accurately as the exec node. See here and here

  • Node-RED version: v1.0.6
  • node.js version: v12.18.0
  • npm version: 6.14.5
  • Platform/OS: Raspberry Pi Raspberry Pi 2 Model B Rev 1.1 running Linux raspbx 4.19.118-v7+ Buster
  • Browser: Chrome
@dceejay
Copy link
Member

dceejay commented Jun 25, 2020

So what are these "unwanted changes" you mention ?
How did you have the exec node configured ? in exec or spawn mode ?
What is not reliable ? Does it crash ? stall ?
What is not accurate ? It just passes on the the data your script gives it so... maybe that is not accurate ?

@colinl
Copy link

colinl commented Jun 25, 2020

In the node-red thread I thought you said you had used debug nodes to document a case where a Switch node was not performing as expected (when fed from a daemon node). In which case it is a problem with the Switch node not the daemon node.

@26tajeen
Copy link
Author

26tajeen commented Jun 25, 2020

In which case it is a problem with the Switch node not the daemon node.

I don't follow this logic - the entire flow was identical apart from the exec or daemon node were swapped around. When swapped back to the exec node it worked reliably.

@colinl
Copy link

colinl commented Jun 25, 2020

You keep saying that, but unless you add the debug nodes, trap a failing situation, and fully analyse it to work out which node is not behaving as you expect then there is nothing to go on. Either the exec node is returning something it shouldn't (or not returning something it should) or one of the other nodes is misbehaving. Unless you can tie it down it is impossible to investigate.

@knolleary
Copy link
Member

Of the two threads linked to, the more relevant one is this one: https://discourse.nodered.org/t/move-from-exec-node-to-daemon-node-has-caused-an-unusual-problem/28566

This thread describes the actual issue in swapping the Exec node for the Daemon node. From that thread, @lancelon shared this Debug output:

Move_from_exec_node_to_daemon_node_has_caused_an_unusual_problem_-_General_-_Node-RED_Forum

The main takeaway is the last entry - compared to the other entries, you can see it contains two lines of std out from the process and not just one.

So the question is whether there is a difference between the Exec and Daemon nodes' handling of stdout - and how the output is split into individual messages.

If both nodes just pass on output as and when they receive it from the child process, then the question is why does the daemon's child process sometimes return more than the exec node's child process.

@26tajeen
Copy link
Author

Thanks. @knolleary has put it better than I could have. Another thing is exec and daemon nodes seem to handle carriage returns differently. I know I "keep saying it" but the Daemon node was unreliable and the exec node was reliable with the exact same flow. So I don't think it's the child process that's at fault because it was consistently consistent with the exec node. I'm OK now because I've moved over to the AMI connector node but I just thought it might be worth flagging this up here so it was raised somewhere. Sorry if that was the wrong thing to do. My head is a bit scrambled at the moment.

@dceejay
Copy link
Member

dceejay commented Jun 25, 2020

not a problem to log it here. I'm just trying to understand how you had them configured exactly (well the exec node - as that has two different modes (and the daemon node doesn't) ) - The spawn mode of exec does return one line at a time and the exec mode waits for all it's output. However even in both modes they rely on how stdout gets flushed from your app... for example python has an optional -u parameter to make sure the output is unbuffered and comes out directly, without that flag python will batch up lines until it decides to send them. I have no idea if php has a flush option for output... it probably does somehow.

So assuming you had the exec in spawn mode...??? then the daemon node also uses spawn mode - but does handle the output slightly differently. The exec node automatically tests the output to see if it is utf8 (string) and if so assumes it's a string and sends a string - whereas the daemon node you get to select what format you want. And it has two string like options -
image
one to return a string (so the same (in theory) as the exec node - and another to return multiple lines - which actually splits lines on the \n character - so in fact maybe that option would "fix" it for you - unless there is some other wrinkle we don't yet know about.

Glad you've got it working with the AMI node - but any clues you can share here would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants