I have played with procrun a bit more and realized that SCM waits for at most 
two minutes. After that, it shows a message saying it got no response from the 
process and displays "stopping" as status on the service. But when the process 
finally ends, it shows "stopped" status (you have to manually refresh the SCM). 
Procrun has a parameter "StopTimeout", which "Defines the timeout in seconds 
that procrun waits for service to exit gracefully."  What happens after the 
timeout period? Does procrun shut down the JVM?
Thanks.

James

-----Original Message-----
From: Mladen Turk [mailto:mt...@apache.org] 
Sent: Thursday, May 31, 2012 2:16 PM
To: user@commons.apache.org
Subject: Re: Commons daemon - stop the service

On 05/31/2012 07:53 PM, James Wang wrote:
> Thanks for the comments.
> I set both start mode and stop mode to JVM.

OK.

> What will happen when a thread needs 20 more minutes to complete its job?

Well for something like that procrun is not the toolkit to use.
First of all, if you need to frequently start/stop service why using the 
service at the first place?
The sole purpose of service concept is to start the application at boot mode or 
on demand and to start them in correct order.

Then there is absolute limit which OS imposes on the service shutdown timeout, 
and this is for all services on the system, see 
http://support.microsoft.com/kb/Q146092

So the only clean solution is that your shutdown code does the actual cleanup 
causing the clean exit.

By spec, JVM won't exit if you have non-daemon threads running, so if you cant 
make them exit, then the only solution is System.exit, which calls OS process 
_exit() which causes the SCM to think service failed.

Also you should design your application differently for service and command 
line mode.

Procrun does not need to call the main() method.
Take a look at Tomcat. We call Bootstrap start/stop methods and main() calls 
Bootstrap.start (after setting correct mode)



Regards
--
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to