Sunday Apr 26, 2009

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!

Friday Oct 05, 2007

How to start JavaDB/Derby as a Windows Service

As I've recently started using the built-in Java DB support in GlassFish, I want the Java DB Network Server to start automatically along with GlassFish.

 I discovered that I can use the exact same method and program that's used for GlassFish-as-a-service.

On Windows, I used this script to setup a Windows Service that automatically starts the Java DB Network Server.  You can change the paths, run it once and the DB will start automatically as a service.

 

@echo off
if "%1A"=="A" goto usage
if "%2A"=="A" goto usage

echo on
sc create %1 binPath= "C:\\as\\lib\\appservService.exe \\"C:\\as\\bin\\asadmin.bat start-database --dbhome %2\\" \\"C:\\as\\bin\\asadmin.bat stop-database\\""  start= auto DisplayName= %1
goto end

:usage
echo usage createDBservice  name dbhome

:end


 

Tuesday May 29, 2007

Start and Stop Scripts

A little known fact: there are scripts for starting and stopping the 3 different kinds of Glassfish servers. The three kinds of servers are:

  • Domain Administration Server (the only server available in a development profile)
  • Node Agent Server
  • Instance Server

These scripts have always been there but were never officially supported.  They were difficult to use.  E.g. you had to know to type in username, password and master password into the void at the command window for strtserv to work.  The scripts were used internally in pre-V2 versions.  They are not used at all in V2.  They are there for your use exclusively now.

Where Are These Scripts?

They are named: 

   Start Script
 Stop Script
 Windows  startserv.bat  stopserv.bat
 Not Windows
 startserv  stopserv

 

In my own personal default environment, they are here:

 Domain Administration Server
c:/as/domains/domain1/bin
Node Agent Server
c:/as/nodeagents/na/agent/bin
Instance Server
c:/as/nodeagents/na/i1/bin
 

How Do I Use Them?

To start a server run the appropriate startserv script.  It will ask you for the administrator's username, pssword and the master password.  If you don't know what a master password is -- just enter changeit.  This is not really needed for the Domain Administration Server in a developer profile, but the script does not yet have the smarts to know whether or not the server is secure.  A future release may fix this problem. 

To stop a server simply run the stopserv script.  No authentiction information is needed or asked for.

 Features

  •  The scripts are relocatable.  I.e., if you use asadmin backup-domain and asadmin restore-domain to clone a domain to a different location -- the scripts will still work.
  • Shutdown is very fast and efficient.
  • This is the only way you can start an instance with no running Domain Administration Server and no running Node Agent Server.
  • You can take over the lifecycle management of one or more Instance Servers.  If you start the Instance Server with the script then the Node Agent Server will not automatically stop it when the Node Agent Server is stopped.


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