[FEATURE] Gateway startup script - detecting the cause of startup

Since Ignition 8.1.18, gateway startup script is executed:

  • each time the gateway master or backup became active (before 8.1.18, only the first node becoming active)
  • each time shared script lib are saved

It would be usefull if we could have an information to know the resaon of the startup.
For example to avoid to re-execute some traits in the startup script (or all the startup script) if the cause is "shared script lib are saved" which can occur very frequently during development.

We can't achieve this by storing a memory flag "startup-done" with system.util.getGlobals() because we wiuld have to reset it on gateway restart or gateway failover.

This has always been true. One of the uses of system.util.getGlobals() is to place a flag to distinguish the "real" first gateway startup from later ones.

Yes sure this behavior has not changed.

In my use case, I build some cache data at the gateway startup, I need to rebuild the cache each time the gateway became active. (especially with a redundant gateway).

So the gateway startup is just fine; but I would like to avoid to rebuid my cache each time the script is triggered by lib change and script save.
If I use a flag, I need to reset it on gateway failover...

Master => startup => flag True Failover => Backup => startup => flag True Failover => Master flag True :frowning: avoid script startup Failover => backup flag True :frowning: avoid script startup.

To achieve my goal, I use a listener for the redundant state change in a module, but it's a bit cumbersome...

If I could know the reason in startup script, (reason = startup, reason = script reload), I could simply do nothing in case of script reload.

I think it could be really usefull in many case where you don't wan't to execute all the startup script at each script save

You can vote for this:

Hi, I face the same problem. Would it be possible for you to share this module with the community ? Thanks :slight_smile: