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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Andrea Lo Pumo
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Andrea Lo Pumo
Does anyone have an answer?

Best regards.

2017-10-23 15:53 GMT+02:00 Andrea Lo Pumo <[hidden email]>:

> 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?
>
Reply | Threaded
Open this post in threaded view
|

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

Mark Thomas
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 <[hidden email]>:
>
>> 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: [hidden email]
For additional commands, e-mail: [hidden email]