# Can a function node detect when re-deployed?

**URL:** <https://discourse.nodered.org/t/can-a-function-node-detect-when-re-deployed/2310>\
**Category:** General\
**Created:** [15 August 2018 15:46 UTC](https://discourse.nodered.org/t/can-a-function-node-detect-when-re-deployed/2310 "2018-08-15T15:46:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [15 August 2018 15:46 UTC](https://discourse.nodered.org/t/can-a-function-node-detect-when-re-deployed/2310/1 "2018-08-15T15:46:10Z")

</div>

I'm thinking that the answer is no but just checking

Simon

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [15 August 2018 15:52 UTC](https://discourse.nodered.org/t/can-a-function-node-detect-when-re-deployed/2310/2 "2018-08-15T15:52:19Z")

</div>

Hi Simon,

Isn't the close event what you are looking for?

Bart

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [15 August 2018 15:56 UTC](https://discourse.nodered.org/t/can-a-function-node-detect-when-re-deployed/2310/3 "2018-08-15T15:56:11Z")

</div>

I was looking to restore the status text - now that I can use Blockly to set it 🙂 - when a re-deploy takes place

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 August 2018 15:58 UTC](https://discourse.nodered.org/t/can-a-function-node-detect-when-re-deployed/2310/4 "2018-08-15T15:58:05Z")

</div>

The Close event tells you when the node is being closed, but there is no equivalent event in the Function node for when it is created as part of a deploy.

Maybe there should be....

---

<div class="post-metadata">

**Author:** ![ncherry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ncherry/32/27_2.png) [@ncherry](https://discourse.nodered.org/u/ncherry)\
**Post date:** [16 August 2018 13:25 UTC](https://discourse.nodered.org/t/can-a-function-node-detect-when-re-deployed/2310/5 "2018-08-16T13:25:09Z")

</div>

For a function node (basically a flow) just add an inject node that triggers once. That can run into a function node which updates what you need.

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [16 August 2018 14:31 UTC](https://discourse.nodered.org/t/can-a-function-node-detect-when-re-deployed/2310/6 "2018-08-16T14:31:06Z")

</div>

The inject once node is I think a good and adequate solution to the detecting a flow startup, even as a complete node-red newbie it was obvious to me as a way to do it and I, perhaps mistakenly, assumed it was the reason for the inject once option. But with the addition of persistent across restart storage, I think a "flow is stopping" hook would be essential to insure that persistent storage gets flushed properly.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [16 August 2018 14:51 UTC](https://discourse.nodered.org/t/can-a-function-node-detect-when-re-deployed/2310/7 "2018-08-16T14:51:49Z")

</div>

> [@ncherry](#):
>
> For a function node (basically a flow) just add an inject node that triggers once

Yes - that's the workaround I'm currently using

---

<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:** [16 August 2018 15:06 UTC](https://discourse.nodered.org/t/can-a-function-node-detect-when-re-deployed/2310/8 "2018-08-16T15:06:11Z")

</div>

> [@wb666greene](#):
>
> But with the addition of persistent across restart storage, I think a "flow is stopping" hook would be essential to insure that persistent storage gets flushed properly.

Node red will look after that for you, you don't need to worry about it.
