Gateway Startup script only on actual startup

Hi,

Theres some things I need to happen once and only once during startup and shutdown, but the issue is whenever someone makes any change to any gateway script in the designer, both gateway startup and shutdown scripts appear to run.

How can I handle this condition so those things only run during an ACTUAL gateway start /stop?

Thanks!

I recommend setting a flag in the dictionary from system.util.getGlobals() (but beware of breakage in v8.0 not fixed until 8.1). Skip your core logic in your startup event if the flag is already present in that dictionary.

True shutdown is more trouble. I recommend not using the shutdown event, but rather adding a shutdown hook to the Java VM. Do so in the startup event. Consider keeping that logic unconditional in the startup event, so that edits will register any changes made to your hook. Use the getGlobals() dictionary to hold a copy of the hook thread so you can unregister the prior handler if the event re-executes.

If you use a JVM shutdown hook, be sure to follow its rules.

I had to separate startup scripts into its own project. (Should mention it was at 8.0+)