James Lampert wrote:
In my experience, Tomcat's "shutdown.sh" has never worked reliably on AS/400, and I don't know why, or even understand enough about how it works (or enough about shell scripts) to troubleshoot it.

Here's the script. I can tell that it eventually transfers control to catalina.sh (which is also what launches Tomcat), but that's about all I can make out without help.


Without looking at the Tomcat Java code itself, this is my take on it :

- shutdown.sh's main purpose is to locate and execute catalina.sh with the single argument "stop".

- catalina.sh, when called with a "stop" argument (and without the "-force" 
option) :
- starts another instance of the JVM, to run another instance of Tomcat, with the argument "stop". Let'scall this the "shutdowner" Tomcat.

- this other "shutdowner" instance of Tomcat parses the same conf/server.xml as the main tomcat instance, and in particular the tag :
        <Server port="8005" shutdown="SHUTDOWN"> (default values shown)
From there, it picks up the "shutdown port" which the main Tomcat should have opened in LISTEN mode (iow a listening, server socket), and the string in the "shutdown" attribute. Then this "shutdowner" Tomcat instance attempts to open a client connection to this port on localhost, and if succesful sends the picked-up shutdown string over that connection.

Back to the running Tomcat, which is listening on that server port.
It receives the connection request from the "shutdowner" Tomcat. If the connection is made from the same host (localhost, 127.0.0.1), it accepts it. If so, it next receives over that connection, the string sent by the "shutdowner" Tomcat, compares that with the string in its own <Server> tag, and if they match, it starts shutting itself down.

Back to the "shutdowner" Tomcat : when it has been succesful opening the connection to localhost:shutdown-port and sending the shutdown string over it, it closes the connection and terminates. This also causes its own "catalina.sh stop" script to terminate.

And everyone is happy.
Of course, if anything in the sequence above misfires, someone will be unhappy.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to