Working with multiple Gateways - Scripting

Hey,
I was wondering how one would handle scripting on multiple gateways, meaning if I build my own scripting library that I want to use for all projects on all gateways, how do I ensure that all gateways have access to the newest version of my library?

I could always manually copy them over but that will surely lead to problems down the line.

Could gateway networks be helpful there? I haven't played around with them.
Anyone has a solution for this?
BR

You could use the GAN with EAM to sync up selected resources between projects, but it wouldn't be automatic, you would need to initiate the sync manually.

Workaround. Connecting both gateways. I haven´t share scripts, just tags,
You can research

Set up your gateways connection

use message handlers between them

Example: Call a script on a remote gateway

On the remote gateway (define a message handler in a project):

# Name: 'remoteScriptHandler'
def handleMessage(payload):
    arg = payload.get("arg")
    return {"result": arg.upper()}

On the local gateway:

response = system.util.sendRequest(
    project='RemoteProject',
    messageHandler='remoteScriptHandler',
    payload={'arg': 'hello'},
    gateway='RemoteGatewayName',
    timeout=5000
)
result = response['result']
1 Like

I wouldn't call it a workaround. I would call it the solution.

It's the only way that I know of to have a script on one gateway executed from another gateway.

2 Likes

For a client with the same requirement, I created a Global project (where all global resources are defined - including a script library), which is sync'd periodically (daily, via EAM task) to all gateways under the umbrella. There, all projects which need access to these scripts are intended to be created with the Global project as a parent project.

I suppose one could build an "On Update" event which automatically runs the EAM task whenever the Global project is saved... Since editing global resources is not a regular occurrence, and since it's beneficial to verify/test changes before pushing everywhere, we initiate a "Run Once" on the EAM task after any changes are made. Worst-case, everything will synchronized again 'by tomorrow'.

1 Like