GlassFish V3 Remote Restart Now Available

GlassFish V3 is now sporting a brand new capability:  Remote Restart.

This feature is particularly handy for environments where the server machine is secured and difficult to get to.  With the right credentials you can now restart the server from anywhere in the world -- as well as from the same machine. 

It is very easy to use.  As of today there are two ways to call the restart-domain command with the third method coming online soon

(1) Use a URL in a browser: 

http://yourhost:4848/__asadmin/restart-domain 


(2) Use asadmin like so:
   asadmin --host yourhost restart-domain

(3) Coming soon:  Admin Console GUI support for the command

The asadmin command, restart-domain, is what I like to call a "hybrid" command.  It is both a local and a remote command.  The local portion of the command's job is to block until it verifies that the server has completed its restart and is online and ready to go.  The remote portion does the actual restarting.

Details

There are 3 main flavors of starting non-embedded V3.  Restart-domain works with all three:

  • Starting the server with the launcher (i.e. asadmin start-domain).  Restarting will stop the running server and once the JVM process is guaranteed to have exited the server will restart.  There are no special "watchdog" processes involved.  The server itself does the work itself in what I like to call "reincarnation".  This is easy to see by running jps during the restart.  You will see the process id change.  You can also watch the server log as the server restarts.
  • Starting the server with the launcher in verbose mode (i.e. asadmin start-domain --verbose).  The key point here is that we have to preserve the console that asadmin owns here.  So we do the restart a little differently.  Since the asadmin process is also running  on the server machine, we ask the already running asadmin process to restart the server for us.  asadmin does all the heavy lifting here.
  • Starting the server in implanted mode (e.g. java -jar glassfish.jar).  A new jvm will be started with exactly the same commandline arguments.  Note that if the server owns the console -- i.e. is running "in the foreground" and mirroring log messages -- the new server will lose control of the console.  We can not absolutely guarantee a clean shutdown without literally closing down the JVM itself.  Once that is done the console is out of reach.

Give it a try!

Comments:

Wonderful news!!! I've been waiting and asking for this feature since forever. It works like a charm. Thanks a lot!

One q: you say that no watchdog is involved, but b46 suggests otherwise:
Launching Watchdog in a separate JVM. The Domain is now remote-restart enabled.

I also see:
501 7861 1 0 0:00.12 ttys002 0:00.62 /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java -cp bin/../glassfish/modules/admin-cli.jar -DGF_FINAL_WATCHDOG_PROCESS=true com.sun.enterprise.admin.cli.ASWatchdog start-domain domain1

Posted by Igor Minar on April 27, 2009 at 12:27 AM PDT #

Thanks for the comments.

Very sharp of you to notice! The first implementation uses a watchdog process. That has been in place for 2 weeks. I just finished implementation 2 on April 26, 2009. It does not need or use a watchdog.

Try build 47 or later...

Posted by Byron Nevins on April 27, 2009 at 02:10 AM PDT #

Cool. Just out of curiosity: How is it implemented? Via JVM hooks?

Posted by Igor Minar on April 27, 2009 at 03:43 AM PDT #

Igor,

The key is to get together some utility/glue classes. Whenever you see something that you had to do in almost every project -- add it to these helpers.

You can start out by getting everything working perfectly in ONE application.

I have a simple home website that has a group of applications that do what your talking about --
form page where they enter info about themselves -- including a username, email address and password.

It creates and adds the account to the DB. It sends an email with a special number that they have to click on. This takes them to a welcome page. Their account is now active.

All the apps use the single sign-on feature
-- GlassFish does all the heavy lifting here once you have it setup.

A also created a crude, simple Web App that allows me to Administer the db with the users.
Of course you can do this directly with the DB too.

I may write a blog about this when I get time.

Posted by W Byron Nevins Jr on April 30, 2009 at 04:47 PM PDT #

Oops that comment was meant for a different blog of mine!

Posted by W Byron Nevins Jr on May 01, 2009 at 05:38 AM PDT #

Oops that comment was meant for a different blog of mine!

Igor,
It works in 2 different modes.

(1)
If you start with the "--verbose" option then you already have an extra JVM hanging around anyways and it just happens to have a reference to the server process. The server also knows that you started in verbose mode. The server does a "System.exit(10)". The verbose console sees the 10 and restarts the server reusing the same console. You can do this ad infinitum

(2)
If you just do a normal start then there is no extra process around. In this case the server spins off another JVM process just before dying. This process runs whatever you ran in the first place. asadmin, java -jar, whatever.
The spawned process is connected to the dying server's standard streams. It blocks on System.in.read() until it gets EOF (-1). That is the very reliable signal that the old server is totally dead. At tht point the new process fires up the server.

Posted by W Byron Nevins Jr on May 01, 2009 at 05:45 AM PDT #

Oops that comment was meant for a different blog of mine!

Igor,
It works in 2 different modes.

(1)
If you start with the "--verbose" option then you already have an extra JVM hanging around anyways and it just happens to have a reference to the server process. The server also knows that you started in verbose mode. The server does a "System.exit(10)". The verbose console sees the 10 and restarts the server reusing the same console. You can do this ad infinitum

(2)
If you just do a normal start then there is no extra process around. In this case the server spins off another JVM process just before dying. This process runs whatever you ran in the first place. asadmin, java -jar, whatever.
The spawned process is connected to the dying server's standard streams. It blocks on System.in.read() until it gets EOF (-1). That is the very reliable signal that the old server is totally dead. At tht point the new process fires up the server.

Posted by W Byron Nevins Jr on May 01, 2009 at 05:46 AM PDT #

cool. thanks!

Posted by Igor Minar on May 01, 2009 at 10:40 AM PDT #

Hey Byron!

I'm watching the Niner game. I was telling my wife about where your seats are/were near the end zone and I thought I would see if I could find you. If you get this, I hope your doing fine!

Take care,

Jeff

Posted by Jeff Schulken on August 14, 2009 at 01:21 PM PDT #

Hi Byron,

Would you like to share the code of how to reboot server remotely... because I still not found the code yet.

Thanks
Andry

Posted by Andry on April 06, 2010 at 07:00 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

ByronNevins

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today