[node-red-node-daemon] Send a command to a process that is already running

I want to send a command to a process that is already running on daemon node.

I hope the following usage:
image

But every time we put the daemon node, another process starts.

I am avoiding this problem by the following workaround:

  • Sending the topic together with the payload.
  • Using switch node to dispatch by topic.
    But when increasing the topic, the switch node will become more complicated and the readability of the flow will become poor.

So I want to send a command to a process that is already running on daemon node.
I want you to be able to register and select the destination process in the same way as a Serial node or MQTT node.

Is this a good idea?

Sorry I can't spot the difference between the two pictures. Why aren't you wiring all three inputs into one daemon node. That is where the process is running. The process must be one that keeps running and sits waiting for input on srdin.

Sorry, I mistook the 2nd picture.
I replaced the 2nd picture.
Please reconfirm.

Yes that looks correct

What inter-process communications protocol do you intend to use for your daemon? Because in that design decision lies the answer I think.

To ask in another way, if you were doing this from a terminal/command line. You run your executable and it keeps running, how would you send it some information?

Not really a Node-RED problem?

Typical ways to resolve this issue include using an external, common, Message Queue - MQTT is a nice, lightweight example. Or allowing UDP/TCP or UNIX Pipe comms. On Windows, you have other choices for IPCC as well though I'm not really familiar with them. Node-RED can interact using any of these methods.

Your example of the serial node is an interesting one. Under both Linux and Windows, serial ports are exposed using a virtual filing system endpoint. The serial driver runs in the background. So you can send or pipe data to the endpoint at any time as long as you have opened the endpoint for writing. You could actually write your own serial port driver if you wanted to (and knew how).

I'm going to use stdin/stdout to communicate to the daemon process.
I suppose to use the daemon node to talk to the interactive CLI command.

I understand that TCP, UDP or MQTT is one of the best way to communicate to the daemon process, but I want to keep this process simple terminal command.