You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Mario Rübsam <mr...@coderesearch.com> on 2006/03/31 13:10:55 UTC

Restart Geronimo from within Servlet

Hi,

we developed a programm for automated data and program updates. This work
fine with Geronimo but for the users convenience Geronimo should be restarted
automatically after that (Geronimo runs as a windows service).
I noticed the shutdown button in the console and I wonder if it will work to
restart Geronimo from a servlets code?

Any suggestions?

Thanks,
Mario

Re: Restart Geronimo from within Servlet

Posted by Paul McMahan <pa...@gmail.com>.
The console currently shuts down the server by calling
kernel.shutdown() followed by System.exit().  There is also some
dormant code that "reboots" the server by calling Daemon.main(new
String[0]) instead of System.exit().  However, that code is commented
out with the following remark:
// Removed until a better mechanism for rebooting the server is created

When I uncommented the reboot code and tried it out it seemed to have
the desired effect (restarting the kernel) although I don't know if
restarting the kernel alone is sufficient for your needs.  Also,
whoever commented it out obviously had a concern with using this
technique so your mileage may vary :-)

Best wishes,
Paul

On 3/31/06, Mario Rübsam <mr...@coderesearch.com> wrote:
> Aaron Mulder wrote:
> > If the restart code in the console does what you want, then you can
> > execute the same logic from a servlet.  The best way would be to
> > connect to the local server via JMX (which would require the
> > administrator username and password).  You could also connect directly
> > to the Geronimo kernel in the local JVM, though we're hoping to shift
> > our classloader structure to move the Geronimo stuff out of the
> > application classloader, so in a future release of Geronimo, you might
> > need to manually specify classloader dependencies to get this approach
> > to work.
> >
>
> I try to call the shutdown code like in the console. Is this the one
> connected with Geronimo kernel or is this the JMX based shutdown?
>
>
> Matt Hogstrom wrote:
>  > Another option would be to use Java Service Wrapper to monitor Geronimo
>  > and restart it when it shutdown.
>  >
>
> If the JSW has such an option to monitor this would be great, because
> this will resolve the problem of starting a new VM within a dying VM.
> Because a complete restart is needed if Geronimo is updated.
>
> Thanks,
> Mario
>

Re: Restart Geronimo from within Servlet

Posted by Mario Rübsam <mr...@coderesearch.com>.
Aaron Mulder wrote:
> If the restart code in the console does what you want, then you can
> execute the same logic from a servlet.  The best way would be to
> connect to the local server via JMX (which would require the
> administrator username and password).  You could also connect directly
> to the Geronimo kernel in the local JVM, though we're hoping to shift
> our classloader structure to move the Geronimo stuff out of the
> application classloader, so in a future release of Geronimo, you might
> need to manually specify classloader dependencies to get this approach
> to work.
> 

I try to call the shutdown code like in the console. Is this the one
connected with Geronimo kernel or is this the JMX based shutdown?


Matt Hogstrom wrote:
 > Another option would be to use Java Service Wrapper to monitor Geronimo
 > and restart it when it shutdown.
 >

If the JSW has such an option to monitor this would be great, because
this will resolve the problem of starting a new VM within a dying VM.
Because a complete restart is needed if Geronimo is updated.

Thanks,
Mario

Re: Restart Geronimo from within Servlet

Posted by Aaron Mulder <am...@alumni.princeton.edu>.
If the restart code in the console does what you want, then you can
execute the same logic from a servlet.  The best way would be to
connect to the local server via JMX (which would require the
administrator username and password).  You could also connect directly
to the Geronimo kernel in the local JVM, though we're hoping to shift
our classloader structure to move the Geronimo stuff out of the
application classloader, so in a future release of Geronimo, you might
need to manually specify classloader dependencies to get this approach
to work.

Thanks,
    Aaron

On 3/31/06, Mario Rübsam <mr...@coderesearch.com> wrote:
> Hi,
>
> we developed a programm for automated data and program updates. This work
> fine with Geronimo but for the users convenience Geronimo should be restarted
> automatically after that (Geronimo runs as a windows service).
> I noticed the shutdown button in the console and I wonder if it will work to
> restart Geronimo from a servlets code?
>
> Any suggestions?
>
> Thanks,
> Mario
>

Re: Restart Geronimo from within Servlet

Posted by Mario Rübsam <mr...@coderesearch.com>.
Jacek,

I added a JIRA issue GERONIMO-1801 to startup/shutdown category
(hope this is the right cat).

Thanks,
Mario


Jacek Laskowski wrote:
> On 4/3/06, Mario Rübsam <mr...@coderesearch.com> wrote:
>> Hi,
>>
>> Matt Hogstrom wrote:
>>> Another option would be to use Java Service Wrapper to monitor Geronimo
>>> and restart it when it shutdown.
>> thanks for the replies to my questions. I finally found the best way to
>> restart Geronimo with all the ressources closed and the server restarts.
>>
>> I used the Java Service Wrapper as Matt suggested and added some filter
>> settings to the wrapper.conf .
>>
>> # Filter settings
>> wrapper.filter.trigger.1=RestartGeronimo
>> wrapper.filter.action.1=RESTART
>>
>> all other settings like Hernan described here:
>> http://opensource2.atlassian.com/confluence/oss/display/GERONIMO/Configuring+Geronimo+as+a+Windows+Service
>>
>> Now the only thing I did in the servlet is a simple:
>> System.err.println("RestartGeronimo");
>>
>> This triggers the log watch function of the JSW and
>> the wrapper executes the RESTART action.
> 
> Whooow! That's incredibly simple! I have never worked with JSW, but
> after having seen the example I added it to my toolbox. Thanks!
> 
>> Maybe this short example help others to remote restart the
>> Geronimo service via a web interface.
> 
> Good point. Would you like to go on with it, report a JIRA task/issue
> and attach a patch? I could commit the change and the solution of
> yours would be distributed as an integral part of Geronimo's official
> distributions.
> 
> Thanks for sharing it!
> 
>> Mario
> 
> Jacek
> 
> --
> Jacek Laskowski
> http://www.laskowski.org.pl
> 

Re: Restart Geronimo from within Servlet

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/3/06, Mario Rübsam <mr...@coderesearch.com> wrote:
> Hi,
>
> Matt Hogstrom wrote:
> > Another option would be to use Java Service Wrapper to monitor Geronimo
> > and restart it when it shutdown.
>
> thanks for the replies to my questions. I finally found the best way to
> restart Geronimo with all the ressources closed and the server restarts.
>
> I used the Java Service Wrapper as Matt suggested and added some filter
> settings to the wrapper.conf .
>
> # Filter settings
> wrapper.filter.trigger.1=RestartGeronimo
> wrapper.filter.action.1=RESTART
>
> all other settings like Hernan described here:
> http://opensource2.atlassian.com/confluence/oss/display/GERONIMO/Configuring+Geronimo+as+a+Windows+Service
>
> Now the only thing I did in the servlet is a simple:
> System.err.println("RestartGeronimo");
>
> This triggers the log watch function of the JSW and
> the wrapper executes the RESTART action.

Whooow! That's incredibly simple! I have never worked with JSW, but
after having seen the example I added it to my toolbox. Thanks!

> Maybe this short example help others to remote restart the
> Geronimo service via a web interface.

Good point. Would you like to go on with it, report a JIRA task/issue
and attach a patch? I could commit the change and the solution of
yours would be distributed as an integral part of Geronimo's official
distributions.

Thanks for sharing it!

> Mario

Jacek

--
Jacek Laskowski
http://www.laskowski.org.pl

Re: Restart Geronimo from within Servlet

Posted by Mario Rübsam <mr...@coderesearch.com>.
Hi,

Matt Hogstrom wrote:
> Another option would be to use Java Service Wrapper to monitor Geronimo 
> and restart it when it shutdown.

thanks for the replies to my questions. I finally found the best way to
restart Geronimo with all the ressources closed and the server restarts.

I used the Java Service Wrapper as Matt suggested and added some filter
settings to the wrapper.conf .

# Filter settings
wrapper.filter.trigger.1=RestartGeronimo
wrapper.filter.action.1=RESTART

all other settings like Hernan described here:
http://opensource2.atlassian.com/confluence/oss/display/GERONIMO/Configuring+Geronimo+as+a+Windows+Service

Now the only thing I did in the servlet is a simple:
System.err.println("RestartGeronimo");

This triggers the log watch function of the JSW and
the wrapper executes the RESTART action.

Maybe this short example help others to remote restart the
Geronimo service via a web interface.

Thanks,
Mario


Re: Restart Geronimo from within Servlet

Posted by Matt Hogstrom <ma...@hogstrom.org>.
Another option would be to use Java Service Wrapper to monitor Geronimo and 
restart it when it shutdown.

Mario Rübsam wrote:
> Hi,
> 
> we developed a programm for automated data and program updates. This work
> fine with Geronimo but for the users convenience Geronimo should be 
> restarted
> automatically after that (Geronimo runs as a windows service).
> I noticed the shutdown button in the console and I wonder if it will 
> work to
> restart Geronimo from a servlets code?
> 
> Any suggestions?
> 
> Thanks,
> Mario
> 
> 
>