Restart gateway scripts when shared scripts are changed

I really like the new shared script library, but there is a little problem when shared scripts are used in gateway scripts. When i change a shared script and publish it from the dessigner, only the gateway scripts for the currently opened projects are restarted. Gateway scripts from other projects still use the old version of the shared script.
While it is preferable that there are no unexpected restarts of other gateway scripts, this behaviour may cause big trouble when scripts use different versions of the same shared library.
Maybe you can display something like a warning 'Global script xxx changed, depending projects a,b,c will be restarted’. This requires to keep track of imports in gateway scripts, so i can imagine it is no easy task.

I can see that no matter what we do with that, someone will be unhappy with the behavior. :slight_smile: At the very least, we need to get that into the documentation.

I’ll make a ticket so it at least gets on the radar.

I think this is a pretty straight-forward bug - we need to restart all project’s gateway scripts any time the shared script library changes.

You must write your gateway scripts to expect that they may be restarted at any time.

1 Like

I agree, but this requires the initialChange flag to always work. I know there was a bug with this flag but maybe that has been fixed some time ago. I will give it a try with 7.7.

Yes, it makes sense to restart all Project gateway scripts when a shared module is changed.

Another idea is to provide the ability for a gateway script to opt out from using shared modules.

Gateway scripts that opted out of using shared modules would not be restarted when a shared module changed.

Gateway scripts that opted out from shared modules would have shared modules removed from scope. So if an opted out gateway script did reference a shared module it would cause a “module not found” exception during runtime or something similar.

This is just an idea. I haven’t fully evaluated all the factors to know if this would fully make sense.

I think this idea would work in a backward compatible way. Ignition 7.6 projects that are upgraded to Ignition 7.7 would have their gateway scripts opted out of shared modules by default and would not need to be modified to expect restarts.

Chi – we’ve made a fix to an upcoming version of 7.7.0 (-rc2 I think?). With the fix, when you save a change to a shared script, all gateway scripts will be restarted without warning and after the restart, will use the new version of the shared script.

Unfortunately, it’s not practical for us to try to only restart gateway scripts that depend on the shared script – there can be a long, convoluted chain of script dependencies. You should already be designing your gateway scripts with the idea that they can get restarted at any time, so restarting scripts that aren’t using the shared script should not cause problems for you.

Thanks for catching this. :slight_smile:

Thanks for the feedback.

The problem with restarting gateway scripts is the ‘initialChange’ flag. I just downloaded beta5 and found that the old bug for this flag still exists.
The Ignition manual says:[quote]The intialChange variable is a flag (0 or 1) that indicates whether or not this event is due to initially subscribing or not.[/quote] but in reality, the script is sometimes started with the initialChange flag set when the value changes for the first time.
I’m not sure about 7.7, but in earlier versions you’ll loose tag change events after a script restart when the initialChange flag is used.
If it is guaranteed that the script will never be triggered by initial subscribing everything would be fine, but then please remove this flag and update the manual.

I’m having problems with the initialChange flag in 7.7.0. When the initialChange flag is used I miss the first tag change following publishing. Without the initialChange flag my tag change scripts are triggered during publishing. Any solutions for this?

To be clear, do you mean that when you filter based on initialChange, your script does not fire when published, and then does not fire again the 1st time the tag’s value changes?

Correct. With a gateway tag change script

import system
if not initialChange:

Hey, I just fixed this for 7.7.1.

What was happening is that the ‘initialChange’ flag would remain true for both the first and the second change event.

Thanks. Is this in the 7.7.1-rc3 release?

Looks like it made it into 7.7.1-rc2