admin@glassfish.java.net

Re: GlassFish process exit

From: Byron Nevins <byron.nevins_at_oracle.com>
Date: Fri, 29 Oct 2010 16:06:09 -0700

Current thinking:

(1) If the server gets a --force option it means "Stop IMMEDIATELY
without running any hooks". This is expected to occur rarely or never.
(2) If the asadmin commands to stop servers get a "--force" it means --
kill the server with platform tools using the pid that was saved in
"lastpid" file.



On 10/29/2010 3:46 PM, Bill Shannon wrote:
> This change addresses many of the issues below, but it seems like
> it's working against 13593. Is that why you filed this:
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=14304
>
> Seems to me that the --force ought to be done *outside* the app server
> process, so that we can kill it no matter what state it's in. But that
> means lots of platform-dependent code. See for instance this blog:
> http://blogs.mulesoft.org/tcat-server-restarts-extend-improve-and-automate-stock-tomcat-restarts/
>
>
>
>
> Tom Mueller wrote on 10/29/10 06:37 AM:
>> Byron,
>> I'd like to discuss this commit at the next admin iteam meeting on
>> Tuesday.
>> http://wikis.sun.com/display/GlassFish/AdminIteam
>> Specifically, what we now expect for fixing other related bugs.
>>
>> What this is saying is that the GlassFish process will never exit by
>> returning
>> from the main thread. It will always either do a System.exit() or be
>> killed.
>> This effects several other issues:
>>
>> 13780 - for getting all threads to be daemons (Tom) - dup of 13957
>> 13957 - Non-daemon threads prevent clean shutdown (Byron)
>> 13593 - logging is terminated too early during appserver shutdown
>> (Naman)
>> 13592 - asadmin stop-local-instance does not stop instance with
>> outstanding ejb
>> invocation (Marina)
>>
>> Your comment in issue 13951 about not having control over apps creating
>> non-daemon threads seems to be the important issue here.
>>
>> Tom
>>
>> On 10/28/2010 7:12 PM, bnevins_at_dev.java.net wrote:
>>> Author: bnevins
>>> Date: 2010-10-29 00:12:29+0000
>>> New Revision: 42283
>>>
>>> Modified:
>>> trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopDomainCommand.java
>>>
>>>
>>> trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopServer.java
>>>
>>>
>>> Log:
>>> --IT 13951
>>> --force is now false by default for stop-domain and stop-instance
>>> If it is false then we call Syste.exit()
>>> If it is true we do an OS-level call to kill on our pid
>>>
>>>
>>>
>>> Modified:
>>> trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopDomainCommand.java
>>>
>>>
>>> Url:
>>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopDomainCommand.java?view=diff&rev=42283&p1=trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopDomainCommand.java&p2=trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopDomainCommand.java&r1=42282&r2=42283
>>>
>>>
>>> ==============================================================================
>>>
>>> ---
>>> trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopDomainCommand.java
>>>
>>> (original)
>>> +++
>>> trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopDomainCommand.java
>>>
>>> 2010-10-29 00:12:29+0000
>>> @@ -77,7 +77,7 @@
>>> @Inject
>>> ServerEnvironment env;
>>>
>>> - @Param(optional=true, defaultValue="true")
>>> + @Param(optional=true, defaultValue="false")
>>> Boolean force;
>>>
>>>
>>>
>>> Modified:
>>> trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopServer.java
>>>
>>> Url:
>>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopServer.java?view=diff&rev=42283&p1=trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopServer.java&p2=trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopServer.java&r1=42282&r2=42283
>>>
>>>
>>> ==============================================================================
>>>
>>> ---
>>> trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopServer.java
>>>
>>> (original)
>>> +++
>>> trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/admin/StopServer.java
>>>
>>> 2010-10-29 00:12:29+0000
>>> @@ -41,7 +41,12 @@
>>>
>>> import com.sun.enterprise.module.ModulesRegistry;
>>> import com.sun.enterprise.module.Module;
>>> +import com.sun.enterprise.universal.process.ProcessManager;
>>> +import com.sun.enterprise.universal.process.ProcessManagerException;
>>> +import com.sun.enterprise.universal.process.ProcessUtils;
>>> import com.sun.enterprise.util.LocalStringManagerImpl;
>>> +import com.sun.enterprise.util.OS;
>>> +import java.util.logging.Level;
>>> import java.util.logging.Logger;
>>>
>>> import java.util.Collection;
>>> @@ -60,7 +65,6 @@
>>> */
>>> protected final void doExecute(ModulesRegistry registry, Logger logger,
>>> boolean force) {
>>> logger.info(localStrings.getLocalString("stop.domain.init", "Server
>>> shutdown
>>> initiated"));
>>> - boolean noSysExit =
>>> Boolean.parseBoolean(System.getenv("AS_NO_SYSTEM_EXIT"));
>>>
>>> Collection<Module> modules = registry.getModules(
>>> "org.glassfish.core.glassfish");
>>> @@ -72,9 +76,32 @@
>>> logger.warning(modules.size() + " no of primordial modules found");
>>> }
>>>
>>> - if (!noSysExit&& force) {
>>> + if(force)
>>> + kill();
>>> + else
>>> System.exit(0);
>>> - }
>>> }
>>> +
>>> private final static LocalStringManagerImpl localStrings = new
>>> LocalStringManagerImpl(StopServer.class);
>>> +
>>> + /*
>>> + * No more Mr. Nice Guy!!
>>> + * we should NOT return from here!
>>> + *
>>> + */
>>> + private void kill() {
>>> + int pid = ProcessUtils.getPid();
>>> + ProcessManager pm = null;
>>> + try {
>>> + if (OS.isWindowsForSure())
>>> + pm = new ProcessManager("taskkill", "/pid", "" + pid);
>>> + else
>>> + pm = new ProcessManager("kill", "-9", "" + pid);
>>> +
>>> + pm.execute();
>>> + }
>>> + catch (ProcessManagerException ex) {
>>> + // ignore
>>> + }
>>> + }
>>> }
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: commits-unsubscribe_at_glassfish-svn.dev.java.net
>>> For additional commands, e-mail:
>>> commits-help_at_glassfish-svn.dev.java.net
>>>
>

-- 
Byron Nevins  -  Oracle Corporation
Home: 650-359-1290
Cell: 650-784-4123
Sierra: 209-295-2188