# Kill node red if commands occurring too fast

**URL:** <https://discourse.nodered.org/t/kill-node-red-if-commands-occurring-too-fast/83775>\
**Category:** General\
**Created:** [17 December 2023 08:05 UTC](https://discourse.nodered.org/t/kill-node-red-if-commands-occurring-too-fast/83775 "2023-12-17T08:05:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [17 December 2023 08:05 UTC](https://discourse.nodered.org/t/kill-node-red-if-commands-occurring-too-fast/83775/1 "2023-12-17T08:05:55Z")

</div>

Hi all

I have a pretty solid flow for my home automation. However, I am still going through a testing phase and there will be times I am away from home.

I would like to kill the node red flow if say 20 commands are triggered within a short time frame, as this would be a bug in the flow and if I am not home, the lights for example may keep flickering on/off and burn out.

Is there a clever way to achieve this?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 December 2023 08:17 UTC](https://discourse.nodered.org/t/kill-node-red-if-commands-occurring-too-fast/83775/2 "2023-12-17T08:17:42Z")

</div>

That is a bit like using a sledgehammer to crack a nut IMO 😉

Instead, you could add delay nodes (set to rate limit mode) inline?

Or you could add a counter that is reset every 60 seconds. If the counter gets above 20, then set a context flag (e.g. `global.inhibit`) then use switch nodes inline that test `global.inhibit` is false.

You could even have an inject set to reset `global.inhibit` every 30 minutes so things start working again after a cool down period.

There are a ton of other ways you could be smarter about this.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [18 December 2023 09:22 UTC](https://discourse.nodered.org/t/kill-node-red-if-commands-occurring-too-fast/83775/3 "2023-12-18T09:22:18Z")

</div>

> [@Steve-Mcl](#):
>
> global.inhibit

thanks for the reply. I've managed to setup a timer to look for the bug if it happens. I need to restart nodered if this occurs, is there a way to do that within the flow without resorting to command line?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 December 2023 09:54 UTC](https://discourse.nodered.org/t/kill-node-red-if-commands-occurring-too-fast/83775/4 "2023-12-18T09:54:52Z")

</div>

You can use an exec node to run the restart command.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [18 December 2023 09:55 UTC](https://discourse.nodered.org/t/kill-node-red-if-commands-occurring-too-fast/83775/5 "2023-12-18T09:55:33Z")

</div>

Thanks Colin - sorry for my ignorance but what is the restart command?

I don't want to reboot the whole machine, which I do know how to do.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 December 2023 10:29 UTC](https://discourse.nodered.org/t/kill-node-red-if-commands-occurring-too-fast/83775/6 "2023-12-18T10:29:01Z")

</div>

> [@Sirhc](#):
>
> what is the restart command

Since you have not told us what OS and hardware you are running on neither do I know the command.

If it is a Pi then from the command line one would use  
`node-red-stop`  
`node-red-start`  
or  
`node-red-reload`

But in an exec node probably better just to restart the service (which is what the above commands end up doing.

`sudo systemctl restart nodered`

You will need to use `sudo visudo` to allow that command to run without needing a password to be entered. No doubt google will tell you how to do that.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [18 December 2023 21:15 UTC](https://discourse.nodered.org/t/kill-node-red-if-commands-occurring-too-fast/83775/7 "2023-12-18T21:15:59Z")

</div>

Thank you - that did the trick!

---

<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:** [16 February 2024 21:16 UTC](https://discourse.nodered.org/t/kill-node-red-if-commands-occurring-too-fast/83775/8 "2024-02-16T21:16:29Z")

</div>

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