Learn how to write scripts that run on shutdown of the Client or the Gateway.

Video recorded using: Ignition 7.7


(open in window)

[00:00] Similar to the startup script, we also have shutdown scripts in both the client and gateway event scripts. So these scripts will run whenever the project restarts in the gateway or when the gateway is shutting down. Similar to, it's like the inverse of how the startup scripts work. So again, in the gateway, you need to realize that this shutdown script may run more than once. It doesn't only run when the gateway is shutting down. It also just runs when the project is restarting inside of the gateway. Also, you should make sure that this script doesn't take a long time to run in the gateway shutdown script, because it will prevent the gateway from shutting down in a timely manner, which can be important because sometimes operating systems, when shutting down, will only give a process a short window of time to shutdown cleanly. In the client scope, we actually have two different versions of the shutdown script. So the shutdown script is run when the client is actually shutting down but a little bit more interesting is the shutdown intercept script, which can be used to interact with the user and intercept the shutdown. So, for example, if the user clicks the red X or whatever the OS close indicator is for the client, this script can run. And it can do things like using a system.util, I'm sorry, system .gui.confirm, to ask the user a question or it could check some sort of condition, and it decides that now is not a great time to shut the client down it can simply set the cancel option on an event object to 1. So when this script runs, there is a variable already in scope called Event, similar to client event handlers. And there's a Boolean on it that you can alter. And so if you, if you have this in your script, and you set the cancel flag to 1, the client won't shut down. So this gives you a chance to intercept that shutdown event.

You are editing this transcript.



Share this video