# Msg.stop support in node-red-node-daemon

**URL:** https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975
**Category:** Developing Nodes
**Created:** [20 July 2023 17:37 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975 "2023-07-20T17:37:45Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![gmarzot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gmarzot/32/81437_2.png) [@gmarzot](https://discourse.nodered.org/u/gmarzot)
#### Post date: [20 July 2023 17:37 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/1 "2023-07-20T17:37:45Z")

</div>

Here is a PR that adds support for a stop message (msg.stop) which will kill suspend restarting the process. it also makes the msg.start message trigger a restart as per existing docs.

first contribution so please feel free to give guidance on whatever ..

> <https://github.com/node-red/node-red-nodes/pull/1018>
>
> \## Types of changes
> 
> \- \[\] Bugfix (non-breaking change which fixes an issue)
> …- \[x\] New feature (non-breaking change which adds functionality)
> 
> \## Proposed changes
> 
> This PR adds support to the node-red-node-daemon for a stop message. When stopped the process will be terminated as per the configured signal and will not be restarted by redo until re-set via a subsequent start message. This PR also makes the start message restart the process as per the existing documentation.  
> 
> 
> \- \[x\] I have read the \[contribution guidelines\](https://github.com/node-red/node-red-nodes/blob/master/CONTRIBUTING.md)
> \- \[\] For non-bugfix PRs, I have discussed this change on the forum/slack team.
> \- \[x\] I have run \`grunt\` to verify the unit tests pass
> \- \[x\] I have added suitable unit tests to cover the new/changed functionality

also i did not see any existing unit tests so no additional ones supplied yet.

---

<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: [20 July 2023 18:00 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/2 "2023-07-20T18:00:04Z")

</div>

Hi. So how does this differ to the existing msg.kill option to stop the process ?

---

<div class="post-metadata">

### Author: ![gmarzot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gmarzot/32/81437_2.png) [@gmarzot](https://discourse.nodered.org/u/gmarzot)
#### Post date: [20 July 2023 18:29 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/3 "2023-07-20T18:29:17Z")

</div>

different in that it sets a flag so that the process will not respawn via the redo timer loop.(cleared by a subsequent msg.start)

I didn't want to mess w/ existing kill behavior and this seemed in keeping with separate messages for start,kill as opposed to some combined behavior.

I was confused by the existing start behavior as it did not agree with the doc that says about causing a restart of the running process.

Anyway, happy for any suggestion or request on how to modify it..

I am using this PR version successfully to selectively start/stop a salt-minion process and no issues encountered so far.

Are there relevant unit tests in this space that I missed?

Thanks for reviewing it.

-G

---

<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: [20 July 2023 19:57 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/4 "2023-07-20T19:57:11Z")

</div>

in the node - if you deselect the relaunch option then msg.kill will stop the process and it won't automatically restart, and will wait for a msg.start. Likewise if you deselect the autostart it won't start on deploy and will wait for a msg.start message.

So I'm still not seeing what extra capability this is adding yet...

---

<div class="post-metadata">

### Author: ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)
#### Post date: [20 July 2023 20:11 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/5 "2023-07-20T20:11:27Z")

</div>

@dceejay Slightly off topic but, I was using the `node-red-node-daemon` node today and had a look through the code and saw that it may support a `msg.cr` property as a boolean. I'm I correct in assuming that the property can be used to "Add [enter] to a message sent"? I couldn't find anything about it in the nodes help documentation and solved my issue without it anyway but would be nice to clarify for future projects.

---

<div class="post-metadata">

### Author: ![gmarzot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gmarzot/32/81437_2.png) [@gmarzot](https://discourse.nodered.org/u/gmarzot)
#### Post date: [20 July 2023 20:24 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/6 "2023-07-20T20:24:35Z")

</div>

I want the managed process to restart typically, so that option is selected at flow creation time,

However, during runtime, a user action, or some other event, may indicate that service needs to be stopped and later may need to be re-enabled.

So I need the restart behavior controllable via message during runtime. This new feature gives that kind of control. Am I missing some other way?

thanks,  
-G

---

<div class="post-metadata">

### Author: ![gmarzot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gmarzot/32/81437_2.png) [@gmarzot](https://discourse.nodered.org/u/gmarzot)
#### Post date: [20 July 2023 20:31 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/7 "2023-07-20T20:31:31Z")

</div>

i can find any link to node-red-contrib-daemon .. but the standard one - node-red-node-daemon has that feature supported in the ui.. and it is maintained as [node.cr](http://node.cr) in the code..

what is the other one you mention?

 ![image.png](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/46281a05a022f909f79cf872d4cba161a1fee791.png)

---

<div class="post-metadata">

### Author: ![gmarzot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gmarzot/32/81437_2.png) [@gmarzot](https://discourse.nodered.org/u/gmarzot)
#### Post date: [20 July 2023 20:33 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/8 "2023-07-20T20:33:38Z")

</div>

\*can't find

 ![image.png](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/46281a05a022f909f79cf872d4cba161a1fee791.png)

---

<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: [20 July 2023 21:03 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/9 "2023-07-20T21:03:58Z")

</div>

Ah - ok - I get it now... I'll look at the PR with that understanding.

---

<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: [20 July 2023 21:06 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/10 "2023-07-20T21:06:34Z")

</div>

No - the node does not support use of msg.cr - It is a property of the node (node.cr) - that is set at edit time whether to add a cr to each line sent or not. It's can't be changed during runtime via a message.

---

<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: [18 September 2023 21:07 UTC](https://discourse.nodered.org/t/msg-stop-support-in-node-red-node-daemon/79975/11 "2023-09-18T21:07:34Z")

</div>

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