Appserver Stop command - remote code in tight loop

Hi there!

We have an appserver process, which basically starts, and performs a tight loop (REPEAT block), which checks a Sonic queue for messages.

If I then use asbman -stop (or use Progress Exploder), the process doesn't stop - it carries on looping. A -kill command will do the trick, but I wondered if there was some kind of session attribute I could check for in the REPEAT block to see if the agent had received a STOP signal?

I'm looking for a way to handle the shutdown gracefully.

Many thanks,

Andy.
 

sunilnair

Member
You might wish to explore the Appserver "Shutdown" or "Disconnect" procedures, which you can get through the Explorer or through the ubroker.properties file and use them to send an error to your repeat loop.

HTH
Sunil.
 
Hi Sunil,

The appserver is running in state-free mode, so there is no disconnect procedure.

I did look at using the shutdown procedure (setting a global shared variable, which is checked in the loop), but the shutdown procedure doesn't actually fire (got a logging message in there). I guess my startup procedure (which is running the repeat block) is keeping the agent so busy that the shutdown procedure can't run.

Any other ideas?

Ta,

Andy.
 

FrancoisL

Member
Have you tried putting PROCESS EVENTS in your repeat? It might fix your problem.


Hi Sunil,

The appserver is running in state-free mode, so there is no disconnect procedure.

I did look at using the shutdown procedure (setting a global shared variable, which is checked in the loop), but the shutdown procedure doesn't actually fire (got a logging message in there). I guess my startup procedure (which is running the repeat block) is keeping the agent so busy that the shutdown procedure can't run.

Any other ideas?

Ta,

Andy.
 

jdgibson

New Member
Hi Sunil,

The appserver is running in state-free mode, so there is no disconnect procedure.

I did look at using the shutdown procedure (setting a global shared variable, which is checked in the loop), but the shutdown procedure doesn't actually fire (got a logging message in there). I guess my startup procedure (which is running the repeat block) is keeping the agent so busy that the shutdown procedure can't run.

Any other ideas?

Ta,

Andy.


The appserver agent is not properly started until the startup procedure completes with no error. If your repeat loop is in the startup procedure presumably the startup procedure does not complete so your appserver agent hasn't actually started. As it hasn't started this may explain why you can't shut it down.

You probably need to rethink how you are going to do this.
 
Ah, interesting.

At the moment, the startup procedure connects to the Sonic broker, and listens via the REPEAT block.

Instead, we could have no startup procedure at all, and then call a simple .p which does the broker connect and the listen REPEAT via a script on the server. That way, we avoid the startup procedure appearing to "hang".

I'll give it a try.
 
Well, that sort of works.

I now have no startup proc, and I call a .p with the REPEAT remotely. Then I stop via Progress Explorer. The client is disconnected immediately. The appserver process carries on for approx 90 seconds, and then receives the stop request, resulting in the shutdown procedure being fired.

Of course, in this kind of context I wonder why I don't just use a .p called in batch mode from a script. There's no real need for the appserver to be used at all!
 
Top