Updated Project Library Scripts Not Reflecting in Gateway (Ignition 8.1.48)

Hi,

I am facing an issue in Ignition 8.1.48:

  • I have a Gateway Scripting Project RANTRA_NEW with multiple library packages (e.g., OEE_NEW).
  • Any updates or newly added functions in any library script work immediately in the Script Console.
  • However, Gateway scripts (Tag Change Events, Timer Scripts, etc.) continue to use old cached versions of all library scripts.
  • Restarting the Gateway makes the updated code work.
  • We always used to save and publish (merge any new changes on the gateway into the open project).

Attempts / Observations:

  1. Standard imports like import OEE_NEW or from OEE_NEW import my_script in Gateway scripts fail with ImportError.
  2. Tried importlib.reload() on library modules — works in does not affect Gateway script and Script Console too.
  3. Confirmed module availability using system.util.getModules() — shows modules in Designer, but not the updated version package in Gateway.

Questions:

  1. Is there a supported way to dynamically reload updated project library scripts in Gateway scripts without restarting the Gateway?
  2. What is the recommended way to use updated library functions in Tag Events, Timer Scripts, and other Gateway-executed scripts?

Info:

  • Project: RANTRA_NEW
  • Library packages: multiple (OEE_NEW, etc.)
  • Ignition version: 8.1.48

Sometimes we experience this too, when updating code from the script library that is referenced from a component event.

In a production environment, restarting the server or gateway is not a viable option. How can we prevent or work around this issue without requiring a restart?

The script console runs in designer scope. The designer has access to both saved and unsaved resources.

This is likely the root cause of the issues you are seeing. Never import project library scripts. Only reference them by fully qualified names.

For instance this:

from OEE_NEW import my_script
my_script()

Should just be:

OEE_NEW.my_script()

NOTE: Folder names are also required in the path.

Assuming you haven't imported the Libraries anywhere, and you haven't leaked them anywhere by using them unsafely, then saving the project will cause the scripting engine to restart, which will reload the scripts.

Saving an inheritable project will cascade down, causing any projects which inherit from it, to also restart their scripting engines. This can cause missed events and other things where scripts can not run because the scripting engine is unavailable, so caution should, as always, be taken to avoid those types of issues in a production environment.

It should not be nessesary to restart the gateway. I on 8.1 since 8.1.5 and I have never had to restart my gateway in order to get changes in my project libraries to take effect, a project save is the only thing that has ever been requiered.

For Tag Events, it depends on which type you are asking about. For valueChange Tag Events (those that are on the tags themselves), the script must be located in the project which is set as the Gateway Scripting Project. For Gateway Tag Change events, then the scripts must be available to the project in which they are configured.

The same goes for Timer Events, the scripts must be available to the project in which they are configured.

"Other Gateway-executed scripts" is really too vauge to give a good answer to.

5 Likes

Thanks for the clarification. I understand the difference between Designer scope and Gateway scope, and I am not directly importing project library scripts in my Gateway events.

The issue I am facing is that updated functions are not being picked up in production. For example, when I call a function like OEE_NEW.my_script(), the Gateway still seems to use the older version of the function. I also tried using from OEE_NEW import my_script and calling my_script(), but that did not work either.

The project is not an inherited project, and all project libraries are within the same project. The updated functions are not affecting Tag Change or Quality Change scripts, even though I have set the project as the Gateway Scripting Project in the Gateway, so the tag event scripts are in the correct Gateway scope.

Is there a recommended approach to safely ensure that updated project library functions are picked up in Gateway-scoped scripts (Tag Change, Timer, etc.) without requiring a restart or risking missed events during a scripting engine restart?

The only way that I know of that can happen is if you have leaked or forced an old version into memory. For instance if the code is running in a very long running task or infinite loop, then the only way to refresh that version of the code is to kill that thread. The easiest way to accomplish that is to restart the gateway (assuming the thread isn’t somehow orphaned from the gateway).

Importing them as you have now twice said you have tried, but then said you’re not doing, is another way to get into that situation, which is why among other reasons it’s strongly discouraged.

If you’ve truly gotten into a situation where there is an old version of your code running in memory, then the only recourse is to figure out how that is occurring and account for it.

Another way in which this can happen is if you are creating objects and then trying to persist them globally with getGlobals() or other even less supported methods. (If it isn’t clear you should not be doing this.)

The recommended way to update project library scripts used in any scope is saving the project. If you have found yourself in a situation where this does not work, then there is an issue with your code somewhere. Without seeing the code, and how it’s called, there isn’t much we can offer as help.

When you save the project you will see messages about the scripting restarting in the gateway logs. If you don’t there is an issue and you should contact support.

Something you can do to help identify if this is happening is to add a logger which logs a version number when the script is run. Then you would know if the code is being replaced or not.