You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Michael Locasto <ml...@pfsmarketing.com> on 2002/06/14 21:42:35 UTC

[Proposal] James Shutdown Utilities

NOTE: this is pretty long, save for a rainy day. (it's raining here)

Folks,

There has been a recent thread on the james-user list about shutting James
down cleanly from the command line.

AFAIK, there are two ways to shutdown James: Login to RemoteManager at
port 4555 or Ctrl-C from the window where James was started.

Ctrl-C gives a cheery little "JVM exiting abnormally. Shutting down
Phoenix."

Currently, this is the code (in James-2.0a2) that shuts down James:

(in org.apache.james.remotemanager.RemoteManagerHandler.java)

private boolean parseCommand( String command ){
...
       } else if (command.equalsIgnoreCase("SHUTDOWN")) {
            out.println("shuting down, bye bye");
            System.exit(0);
            return false;
        } else {
...
}

What does James need to clean up when it shuts down? (Pools, connections,
file handles, servers/sockets?) Are there shutdown hooks registered for
different pieces of James, or is this something that Phoenix takes care
of? A System.exit( 0 ) is nice and simple, but really no more
"user-friendly" (resource-friendly?) than a Ctrl-C.

Should a ShutdownUtility or a StopJames object be implemented?

For example:

package org.apache.james.util;

public final class StopJames{

    public StopJames(){
        readConfig();
        loadKeyInfo();
        signalJames();
    }

    ...
}

Where:

readConfig() allows StopJames to discover its environment (eg find
the remoteManager port, admin username, admin password from config.xml,
and name of a file or datasource that stores a key or cert)
loadKeyInfo() loads the authentication information
signalJames() contacts the RemoteManager, logs in, and issues the
shutdown, supplying the certificate as proof that it is a valid user. In
addition, RemoteManager could make sure that the connection is from the
local machine IP address.

Whatever the main thread of execution is for James (James.java?) would
have a method shutDown() that calls all other shutDown() methods. The
RemoteManager calls this method.

The certificate could be some unique information:

-generated at James startup
-pre-determined by admin (and non-public)

-AND-

-stored in a file generated at James startup
-stored in LDAP repository
-stored in a database
-etc...


This utility would be invoked from within james.bat (james.sh) start/stop
script like so (in MS Windows-speak):

%JAVA_HOME%\bin\java -cp %CLASSPATH% -Djames.home=%JAMES_HOME%
org.apache.james.util.StopJames

This approach of course relies on the script being executable only by
the owner of James :)

In addition, should a public shutDown() method be included in objects that
would need to clean up after themselves? Clearly, the
ShutdownUtility would have to pass some ?other? certificate or
authenticating information to each object with a shutDown() method. The
purpose of this method would be to give each object a chance to release
resources.

Since James is run as a block in Phoenix, and I'm not really clear on the
details of what this affords you, I could be talking about something
completely useless. If so, I apologize. But I figured this would be a
change of pace from discussing logging. :)

Regards,
Michael









--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Proposal] James Shutdown Utilities

Posted by Michael Locasto <ml...@pfsmarketing.com>.
Andrei,

Gotcha...
I am properly chastened.

Regards,
Michael

----- Original Message -----
From: "Andrei Ivanov" <my...@surfeu.fi>
To: "James Developers List" <ja...@jakarta.apache.org>
Sent: Friday, June 14, 2002 4:03 PM
Subject: Re: [Proposal] James Shutdown Utilities


> Hm, just a side note:
>
> > AFAIK, there are two ways to shutdown James: Login to RemoteManager at
>
> Third way is to start james with wrapper and then stop via wrapper. We
using
> this and this works just fine.
>
> Andrei
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Proposal] James Shutdown Utilities

Posted by Andrei Ivanov <my...@surfeu.fi>.
Hm, just a side note:

> AFAIK, there are two ways to shutdown James: Login to RemoteManager at

Third way is to start james with wrapper and then stop via wrapper. We using
this and this works just fine.

Andrei


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [Proposal] James Shutdown Utilities

Posted by "Noel J. Bergman" <no...@devtech.com>.
Michael,

I haven't looked at the source for Phoenix, so I can't swear that they are
using

  Runtime.getRuntime().addShutdownHook()

but the effect of it appears to be happening.  Phoenix would be responsible
for coordinating exit processing for all of the various components in the
container.

	--- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>