Gateway Shutdown script not executing

I have a simple Startup script and Shutdown script to run in the Gateway, the startup script is fine but the shutdown script does not execute, my question is when does the shutdown script run? I’ve tried stopping and starting the Gateway service and also restarting the Gateway server itself, neither of which runs the shutdown script.
example
Startup script:
value = 1
system.tag.writeToTag(‘GatewayStatus’, value)

Shutdown script:
value = 0
system.tag.writeToTag(‘GatewayStatus’, value)

thanks

You know… it probably is running, but all the systems that need to be up and running in order to write to a tag have probably been shut down at the point that you’re script is executing.

Why don’t you verify this by just putting a print statement in there and looking in the wrapper.log file to see if it shows up.

you’re right it did run, so I guess I can’t write to a tag in a shutdown script?

also, I tested this in a VM and shutting down the Gateway correctly the shutdown script runs fine but I noticed if there is a power loss/unexpected shutdown that the shutdown script won’t run (which is what i’m trying to simulate) What else can I look for in the log to tell me if the gateway had an unexpected shutdown/power loss?

-We have an HMI that runs on battery backup (1 hour then it dies) if not plugged into power so I’m trying to find a way for us to know when a bad shutdown occurs…

thanks

A clean shutdown will produce a myriad of log messages related to that shutdown… including ones that look like these:

INFO   | jvm 1    | 2014/02/14 11:34:10 | INFO  [SRContext                     ] [11:34:10,171]: Ignition Gateway shut down in 6229ms
INFO   | jvm 1    | 2014/02/14 11:34:10 | INFO  [SRContext                     ] [11:34:10,171]: Ignition["/main", state=STOPPING] ContextState = STOPPED
INFO   | jvm 1    | 2014/02/14 11:34:10 | INFO  [BasicExecutionEngine          ] [11:34:10,172]: Execution engine 'fsql' shut down in 0ms
INFO   | jvm 1    | 2014/02/14 11:34:10 | INFO  [BasicExecutionEngine          ] [11:34:10,172]: Execution engine 'TagSubscriptionModel' shut down in 0ms
INFO   | jvm 1    | 2014/02/14 11:34:10 | INFO  [BasicExecutionEngine          ] [11:34:10,172]: Execution engine 'ExecEngine-1' shut down in 0ms
INFO   | jvm 1    | 2014/02/14 11:34:10 | INFO  [Application                   ] [11:34:10,173]: [WicketFilter] destroy: Wicket core library initializer
INFO   | jvm 1    | 2014/02/14 11:34:10 | INFO  [Application                   ] [11:34:10,174]: [WicketFilter] destroy: Wicket extensions initializer
STATUS | wrapper  | 2014/02/14 11:34:10 | <-- Wrapper Stopped

If you see a bunch of startup related messages:

STATUS | wrapper  | 2014/02/14 11:36:07 | --> Wrapper Started as Daemon
STATUS | wrapper  | 2014/02/14 11:36:07 | Java Service Wrapper Standard Edition 64-bit 3.5.15
STATUS | wrapper  | 2014/02/14 11:36:07 |   Copyright (C) 1999-2012 Tanuki Software, Ltd. All Rights Reserved.
STATUS | wrapper  | 2014/02/14 11:36:07 |     http://wrapper.tanukisoftware.com
STATUS | wrapper  | 2014/02/14 11:36:07 |   Licensed to Inductive Automation for Ignition Gateway
STATUS | wrapper  | 2014/02/14 11:36:07 | 
STATUS | wrapper  | 2014/02/14 11:36:07 | Launching a JVM...
.
. Lots more
.

that aren’t preceded by those messages… it was probably a bad shutdown.

ok, so that being said i’m guessing that the shutdown script won’t execute if it’s a bad shutdown such as a power loss…?

and even with a clean shutdown, I can’t write to a tag using a shutdown script?

[quote=“rcorkern”]

-We have an HMI that runs on battery backup (1 hour then it dies) if not plugged into power so I’m trying to find a way for us to know when a bad shutdown occurs…

thanks[/quote]

monitor your ac power with a relay tied to a plc or modbus tcp io module using ignition. you can then have ignition log an alarm when the power goes down and even send you an email. obviously after the ups runs out you are dead.

[quote=“rcorkern”]ok, so that being said i’m guessing that the shutdown script won’t execute if it’s a bad shutdown such as a power loss…?

and even with a clean shutdown, I can’t write to a tag using a shutdown script?[/quote]

Both correct. You’ll need something external, such as what diat150 recommended.