You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Andrea Lo Pumo <al...@movia.biz> on 2017/11/29 11:09:24 UTC

Re: [daemon] Can init() be called more than once in a single JVM session?

Does anyone have an answer?

Best regards.

2017-10-23 15:53 GMT+02:00 Andrea Lo Pumo <al...@movia.biz>:

> Since now, I have always assumed that init() is called once, and no
> more. Now I am not sure anymore. My doubt is that init() can be called
> a second time, after destroy() has been called, for example, if the
> program is restarted by Jsvc. Is this so? If yes, I should use a
> static variable "alreadyInitialized" and do nothing in init() if it is
> true, at least for things that have not to be done more than once.
>
> A second question: when does Jsvc restart the program exactly? If I
> kill the program, or use -stop. It simply stop()s and destroy()s and
> exits. I have been able to simulate a restart using System.exit(123).
> Are there other cases when Jsvc restarts the program?
>

Re: [daemon] Can init() be called more than once in a single JVM session?

Posted by Mark Thomas <ma...@apache.org>.
On 29/11/17 11:09, Andrea Lo Pumo wrote:
> Does anyone have an answer?

My expectation is that init() will be call once per JVM but that the
jsvc process may create multiple JVMs (sequentially, not concurrently)
and that init() will be called for each.

If jsvc detects that the JVM has aborted (OOME, crash, etc.) it uses
exit code 123 to signal a restart. You can call System.exit(123); to
achieve the same result.

Any other clean exit will be treated as a normal shutdown and there will
be no restart.

HTH,

Mark


> 
> Best regards.
> 
> 2017-10-23 15:53 GMT+02:00 Andrea Lo Pumo <al...@movia.biz>:
> 
>> Since now, I have always assumed that init() is called once, and no
>> more. Now I am not sure anymore. My doubt is that init() can be called
>> a second time, after destroy() has been called, for example, if the
>> program is restarted by Jsvc. Is this so? If yes, I should use a
>> static variable "alreadyInitialized" and do nothing in init() if it is
>> true, at least for things that have not to be done more than once.
>>
>> A second question: when does Jsvc restart the program exactly? If I
>> kill the program, or use -stop. It simply stop()s and destroy()s and
>> exits. I have been able to simulate a restart using System.exit(123).
>> Are there other cases when Jsvc restarts the program?
>>
> 


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