Written by

InterSystems Corporation
Question Otto Medin · Oct 4, 2024

Can a business host know that the production is trying to shut down?

Hi all,

Does anyone know of a way for a business host (specifically an operation) to check whether the production it's running in is trying to shut down?

Cheers,

Otto

Product version: IRIS 2024.1

Comments

Jeffrey Drumm · Oct 4, 2024

All Business Host classes that inherit from Ens.Host have the callback method OnProductionStop(). When the production is shut down, that method is called, and in it you can insert code to allow you to control what happens during shutdown of a production.

Edit: OnProductionStop, not OnProductionShutdown

0
Otto Medin  Oct 4, 2024 to Jeffrey Drumm

Thanks!
I found OnProductionStop(), but I'm after something different, along the lines of calling Ens.Director.GetProductionStatus() from within OnMessage() but with a fifth possible state: ProductionStateStopping

What I'm trying to do is custom retry logic that retries on certain errors, which could mean a pretty long total hang time, so it would seem well-behaved to check every second (or so) whether it's time to shut down.
Thinking about it, it would be a lot better to be able to tell whether the host itself should stop. That is, regardless of whether it's because of a production shutdown or a stop/restart of the individual host.

0
Enrico Parisi · Oct 5, 2024

In these situations what I use is:

If ##class(Ens.Job).ShouldBeQuiescent() || ##class(Ens.Job).ShouldTerminate() {
    ; close shop!
    Quit
}

0
Otto Medin  Oct 7, 2024 to Enrico Parisi

Thanks!

Looking at Ens.Job, there's also a ShouldAbort() and ShouldSuspend(). I guess I'll need to handle those, too, right?

0