You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Olivier Lemasle <ol...@apalia.net> on 2013/04/01 13:49:36 UTC

[daemon] Stop and force-stop with jsvc

Hi,

I'm using Apache Commons Daemon and jsvc to run my Java program as a daemon
on GNU/Linux, using Daemon interface.

I'd like to have two "stop" actions:
- a simple "stop" which cancels new tasks and waits for the completion of
active tasks on my application, and then stops;
- a "force-stop", which cancels new tasks, interrupts the active tasks,
and stops.

Is there a way to do this with Jsvc? When I use "jsvc -stop ...", the
method stop() in my class implementing the Daemon interface is called, and
I have no choice to "force-stop". Could you please suggest a way to solve
my issue?

Thanks,

--
Olivier Lemasle

Re: [daemon] Stop and force-stop with jsvc

Posted by Mladen Turk <mt...@apache.org>.
On 04/11/2013 07:08 PM, Olivier Lemasle wrote:
> Thanks for your help!
>

Sure.
BTW, on second thought perhaps the best solution would be to call
signal followed by stop. Signal method could set the flag for stop
method making it "force-stop".

Think this would be safest method, cause signal() alone causing shutdown
could lead to auto restart.


>
> On Tue, Apr 2, 2013 at 6:05 PM, Mladen Turk <mt...@apache.org> wrote:
>
>>>
>>> I'm using Apache Commons Daemon and jsvc to run my Java program as a
>>> daemon
>>> on GNU/Linux, using Daemon interface.
>>>
>>> I'd like to have two "stop" actions:
>>> - a simple "stop" which cancels new tasks and waits for the completion of
>>> active tasks on my application, and then stops;
>>> - a "force-stop", which cancels new tasks, interrupts the active tasks,
>>> and stops.
>>>
>>> Is there a way to do this with Jsvc? When I use "jsvc -stop ...", the
>>> method stop() in my class implementing the Daemon interface is called, and
>>> I have no choice to "force-stop". Could you please suggest a way to solve
>>> my issue?
>>>
>>>
>> You can implement user signal (SIGUSR2) interface which will call signal()
>> method
>> and there you can do what you wish. But I didn't tried to stop the JVM.
>>

Regards
-- 
^TM

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


Re: [daemon] Stop and force-stop with jsvc

Posted by Olivier Lemasle <ol...@apalia.net>.
Thanks for your help!


On Tue, Apr 2, 2013 at 6:05 PM, Mladen Turk <mt...@apache.org> wrote:

> On 04/01/2013 01:49 PM, Olivier Lemasle wrote:
>
>> Hi,
>>
>> I'm using Apache Commons Daemon and jsvc to run my Java program as a
>> daemon
>> on GNU/Linux, using Daemon interface.
>>
>> I'd like to have two "stop" actions:
>> - a simple "stop" which cancels new tasks and waits for the completion of
>> active tasks on my application, and then stops;
>> - a "force-stop", which cancels new tasks, interrupts the active tasks,
>> and stops.
>>
>> Is there a way to do this with Jsvc? When I use "jsvc -stop ...", the
>> method stop() in my class implementing the Daemon interface is called, and
>> I have no choice to "force-stop". Could you please suggest a way to solve
>> my issue?
>>
>>
> You can implement user signal (SIGUSR2) interface which will call signal()
> method
> and there you can do what you wish. But I didn't tried to stop the JVM.
>
>
> Regards
> --
> ^TM
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@commons.**apache.org<us...@commons.apache.org>
> For additional commands, e-mail: user-help@commons.apache.org
>
>


-- 
Olivier Lemasle
Ingénieur Logiciel
*Apalia*™*
*Mobile: +33-611-69-12-11
*http://www.apalia.net
 <ol...@apalia.net>olivier.lemasle@apalia.net*

Re: [daemon] Stop and force-stop with jsvc

Posted by Mladen Turk <mt...@apache.org>.
On 04/01/2013 01:49 PM, Olivier Lemasle wrote:
> Hi,
>
> I'm using Apache Commons Daemon and jsvc to run my Java program as a daemon
> on GNU/Linux, using Daemon interface.
>
> I'd like to have two "stop" actions:
> - a simple "stop" which cancels new tasks and waits for the completion of
> active tasks on my application, and then stops;
> - a "force-stop", which cancels new tasks, interrupts the active tasks,
> and stops.
>
> Is there a way to do this with Jsvc? When I use "jsvc -stop ...", the
> method stop() in my class implementing the Daemon interface is called, and
> I have no choice to "force-stop". Could you please suggest a way to solve
> my issue?
>

You can implement user signal (SIGUSR2) interface which will call signal() method
and there you can do what you wish. But I didn't tried to stop the JVM.


Regards
-- 
^TM

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