commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mladen Turk <>
Subject Re: Commons daemon - stop the service
Date Thu, 31 May 2012 16:15:07 GMT
On 05/31/2012 02:37 PM, James Wang wrote:
> I need some insights on how procrun shuts down an application. Procrun has a parameter
called “StopTimeout” which Defines the timeout in seconds that procrun waits for service
to exit gracefully. What happens after the timeout period? Doe procrun shut down
> the JVM?
> A more general question is: how do the involved parties interact with one another –
JVM, procrun, and Windows service manager? I have been perplexed by two errors: one says the
process ended unexpectedly. The other says service manager could not get a
> response from procrun (after a long wait). In both cases, the event viewer showed errors
related to prunsrv.exe. These errors are more associated with the 32 bit version. AMD64 seems
to work a better.

Depends on the mode you select.
In general service stop is treated as separate process which should by some IPC
mechanism inform the 'service' to stop.

The simplest one is System.exit, which just calls System.exit() for the service.
More complex involves either special process or method call which
must cause main service to exit cleanly.

Shutdown timeout can occur if any of those goes over defined timeout.
Service code should never call System.exit by itself cause that can
lead to 'process ended unexpectedly'.
Reason is because 'stop' waits for 'start' to finish and then 'stopped'
is reported to service manager.

So if your service code uses system.exit then you must use java mode
which spawns a separate process and stop is then program which must
by some IPC (usually socket) inform the 'master' to shut down.

With jvm mode all that happens in the same process (and the same JVM)
thus your stop code must set some variable in main program which will
cause clean exit from main method. This can be tricky if you depend on
daemon threads.

Hope that shares some light.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message