Shutdown() method doesn't do anything

Hello,

I am working on a developing a module. In the shutdown method of GatewayHook of the module, I’m not sure what to put here to have the module actually shutdown. As of right now, the method gets called, and it puts the message it has into the logger, but the method doesn’t actually do anything else.

I’ve seen where some of the module examples will call super.shutdown(), but since GatewayHook extends an abstract class, it throws an error when I try to do that here.

I am working in Ignition 8.0.5 with Java 11.0.4.

Thank you,

shutdown() of your hook is called by the gateway when your module is going to shut down - it’s to give you an opportunity to do any clean up or maintenance tasks, before your module’s lifetime stops.

If you want to manually trigger a module shutdown (I’m not sure why, but assuming you have a reason) you need to go from the GatewayContext your module gets during setup; GatewayContext.getModuleManager().restartModule(<your module's ID>)

There’s no independent method to just trigger a ‘shutdown’ - your module is expected to be ‘running’ as long as the gateway is, outside of restarts. If you’re creating some temporary object with its own lifecycle, then you need to manage that bookkeeping yourself; keep a list or map of those objects in your gateway module hook, then in shutdown, call object.destroy() (or whatever your own objects lifecycle methods are).

Based on your response, I think I might be on the wrong track. I’m currently working on licensing my module, and have gotten it licensed successfully using the API tool, but the Trial version of the module still works outside of the Trial Period on the Gateway.

I found a page that recommended using LicenseState.getLicenseMode() == LicenseMose.Trial and LicenseState.isTrialExpired() to fix this, but assuming both of those are true, I’m not sure what to do next.

React to license state changes (such as trial expiring) by implementing notifyLicenseStateChanged(LicenseState) in your gateway hook. What that means is, again, up to your module/your lifecycle.

For instance, the Webdev module works normally when in trial, or while licensed, but if the trial expires, returns http 402. To do this, the various request endpoints (doGet, doPost, etc) have a check at the very top - if the cached LicenseState on the root module hook returns true for isTrialExpired(), then the function immediately returns the 402 status.

1 Like