MvsCommandCallback and STOP command

General discussion on the JZOS batch launcher and toolkit
Post Reply
gehlert
Posts: 7
Joined: Thu Nov 17, 2005 2:00 pm
Location: Frankfurt, Germany

MvsCommandCallback and STOP command

Post by gehlert »

Why doesn't the MvsCommandCallback class allow me to intercept STOP commands? Would be nice to have an opportunity to shut down cleanly in response to a STOP.

The current implementation seems to just take the JVM down unconditionally by calling System.exit().

I'm aware that malicious code could decide to just ignore the STOP request, but the operator could still issue a CANCEL in this case, so...

Any opinions?
Guest

Post by Guest »

You can use the method java.lang.Runtime.addShutdownHook() to register code that runs at System.exit(). This, for example, is how Tomcat cleanly shuts everything down when you issue an MVS STOP command (on on other platforms, when you press cntl-c or send it a STOP signal).

Please let us know if this doesn't meet your requirements. I'm open to also consider registering a callback for STOP commands in JZOS.
gehlert
Posts: 7
Joined: Thu Nov 17, 2005 2:00 pm
Location: Frankfurt, Germany

Post by gehlert »

Anonymous wrote:You can use the method java.lang.Runtime.addShutdownHook() to register code that runs at System.exit(). This, for example, is how Tomcat cleanly shuts everything down when you issue an MVS STOP command (on on other platforms, when you press cntl-c or send it a STOP signal).

Please let us know if this doesn't meet your requirements. I'm open to also consider registering a callback for STOP commands in JZOS.
Thanks for the quick reply.

Yes, using the JVM shutdown hook is an option. Still, I'd like to register a callback because it would give us the opportunity to warn the operator ("Users still active -- use STOP FORCE to terminate anyway"). Suggestion: JZOS looks at the STOP parm; if it's "FORCE" the JVM is terminated unconditionally, else callback is invoked.

Cheers, Uli
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

I like your suggestion. We'll consider including it in a future release.
Post Reply