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

**URL:** <https://discourse.nodered.org/t/node-red-node-daemon-send-a-command-to-a-process-that-is-already-running/40423>\
**Category:** Feature Requests\
**Created:** [5 February 2021 07:14 UTC](https://discourse.nodered.org/t/node-red-node-daemon-send-a-command-to-a-process-that-is-already-running/40423 "2021-02-05T07:14:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkanjar](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@tkanjar](https://discourse.nodered.org/u/tkanjar)\
**Post date:** [5 February 2021 07:14 UTC](https://discourse.nodered.org/t/node-red-node-daemon-send-a-command-to-a-process-that-is-already-running/40423/1 "2021-02-05T07:14:34Z")

</div>

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

I hope the following usage:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/0/b0667321c0496769b927a3f131da3d2d10665d6b.png)

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

I am avoiding this problem by the following workaround:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/2/d2c45cf36c8a15468a9a0c43f82caf5399aa17c2.png)

- 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?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [5 February 2021 07:27 UTC](https://discourse.nodered.org/t/node-red-node-daemon-send-a-command-to-a-process-that-is-already-running/40423/2 "2021-02-05T07:27:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tkanjar](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@tkanjar](https://discourse.nodered.org/u/tkanjar)\
**Post date:** [5 February 2021 07:48 UTC](https://discourse.nodered.org/t/node-red-node-daemon-send-a-command-to-a-process-that-is-already-running/40423/3 "2021-02-05T07:48:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [5 February 2021 07:58 UTC](https://discourse.nodered.org/t/node-red-node-daemon-send-a-command-to-a-process-that-is-already-running/40423/4 "2021-02-05T07:58:29Z")

</div>

Yes that looks correct

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [5 February 2021 16:53 UTC](https://discourse.nodered.org/t/node-red-node-daemon-send-a-command-to-a-process-that-is-already-running/40423/5 "2021-02-05T16:53:31Z")

</div>

> [@tkanjar](#):
>
> 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?

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).

---

<div class="post-metadata">

**Author:** ![tkanjar](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@tkanjar](https://discourse.nodered.org/u/tkanjar)\
**Post date:** [7 February 2021 23:59 UTC](https://discourse.nodered.org/t/node-red-node-daemon-send-a-command-to-a-process-that-is-already-running/40423/6 "2021-02-07T23:59:02Z")

</div>

> [@TotallyInformation](#):
>
> What inter-process communications protocol do you intend to use for your daemon? Because in that design decision lies the answer I think.

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 April 2021 23:59 UTC](https://discourse.nodered.org/t/node-red-node-daemon-send-a-command-to-a-process-that-is-already-running/40423/7 "2021-04-08T23:59:48Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
