dev@glassfish.java.net

SUMMARY of various ways to start/stop the server [Was: Re: lopsidedness of domaindir usage?]

From: Kedar Mhaswade <Kedar.Mhaswade_at_Sun.COM>
Date: Thu, 11 Sep 2008 10:39:05 -0700

Sorry for the long thread (it was of course essential),
but here is the summary as requested by Lance
and probably wanted by others. I hope this finds some resting place in
documentation ...

Note, there are two parts, one is starting, other is stopping.
Also, these are the ways I know of. There could be others.

Way to start the server Benefits/limitations

1) asadmin start-domain - Works with any domain.
                                     - Reads domain.xml for any java-config
                                       data.
                                     - May take longer as 3 processes are
                                       involved in the default case. The
                                       number reduces to 2 with --verbose. With
                                       --verbose, ^C on terminal (On Unix e.g.)
                                       will end the server process.
                                     - Starts any domain on given file system.

2) java -jar glassfish-x.jar - Starts the VM that server uses, directly.
     (where x is the version) - You undertake the responsibility of
                                       setting VM parameters on command line.
                                     - If you are invoking it from another
                                       Java process, you get a sub-process
                                       handle(e.g. instance of java.lang.Process)
                                       that you can optionally destroy. You can
                                       also redirect standard process streams.
                                     - Meant for power users.

3) Call embedded API from within - Meant only for embedded use.
    your desktop/console application - Domain.xml configuration is irrelevant
                                       and is not consulted while server starts.
                                     - No VM overhead, uses resources from your
                                       ("embedding") VM.

4) Invoking <install>/bin/startserv - Shortcut for 1) with --verbose. Thus by
                                       default "startserv" would start the
                                       default domain in verbose mode.
                                     - Parametrized to deal with any domain. e.g.
                                       startserv --domaindir /Users/kedar mydom

                                       would start a domain named "mydom" in
                                       folder "/Users/kedar" in verbose mode.
                                     - You can use ^C to stop such a process.

In non-embedded case, recommended way of starting the domain/server is 1),
followed by 4).

Way to stop the server Benefits/limitations

1) asadmin stop-domain - Stops any domain, "domain1" by default.
                                     - Causes System.exit() called in server
                                       since --force is true by default.

2) ^C on a console after - Easy enough.
    using 1) with --verbose, - Instant gratification ;).
    2) or 4) above to start


3) stopserv - Does exact opposite of startserv,
                                       parametrized same way.
                                     - Needs another shell to issue the command.

4) http://host:port/stop-domain - Can be invoked from browser.

5) Using embedded API - Meant only for embedded case. I don't know
                                       details of it. Ask Byron/Kohsuke/Vivekp.


In non-embedded case, recommended way is 1), followed by 3) and then 2, 4.

-Kedar
km_at_dev.java.net


Lance Andersen wrote:
> This is getting very confusing. Can we please have someone put together
> a final summary as to the limitations and suggested use cases that work
> and do not work with java -jar vs asadmin vs startserv?
>