You can see more info on your Tomcat processes by increasing the column
display of ps.  For example, on a RedHat box, use "ps -ef --cols=300 |grep
java" and you can see the full command line used to start Tomcat.  In my
environment (multiple, distinct Tomcats) there is a different server.xml for
each instance.  Using the "--cols" option makes it trivial for me to see
exactly which instance is which, and obtain the PID of the instance in
question for stopping purposes.

In addition, Tim Funk posted back in June a roll-your-own solution for
getting the PID of Tomcat anytime you want, from whatever tool you desire,
which I will repost here.  It's not absolutely thorough with every exact
line of code you need, but it should be sufficient for a really good start.
It's a nice little tip/trick:

==== begin repost of Tim's PID solution ====

For what its worth - I created (and use) a LifecycleListener that runs 
on startup which logs the process ID into a file called tomcat.pid. 
Which is created by a shell script called writepid.sh. Below is all the 
code to get this to work. This code also assumes your current working 
directory is $CATALINA_HOME.

--Begin code
import org.apache.catalina.LifecycleEvent;

/**
  * A helper for getting the PID of java so shutting down tomcat is MUCH
  * easier.
  */
public class PidLifeCycle implements org.apache.catalina.LifecycleListener {
      public void lifecycleEvent(LifecycleEvent event)  {
         if ("start".equals(event.getType())) {
            try {
             Runtime.getRuntime().exec("/bin/sh bin/writepid.sh");
            } catch(Throwable e) {
               e.printStackTrace();
            }
         }
      }
}
--End Code

The code above will launch the following shell script. Should be in the 
bin/ directory of your tomcat installation.
--Begin Shell script
echo $PPID > logs/tomcat.pid
--End Shell script

Then add the following into server.xml
--Begin server.xml snippet
<Listener className="PidLifeCycle" />
--End server.xml snippet

==== end repost of Tim's PID solution ====

John


> -----Original Message-----
> From: camccuk [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 11, 2002 1:49 PM
> To: Tomcat Users List
> Subject: Re: Using daemontools to supervise Tomcat
> 
> 
> 
> --- Ben Ricker <[EMAIL PROTECTED]> wrote:
> > I tried to get Daemontools running for Jserv (which is 
> pretty similar)
> > and had no luck. My guess is that you might be able to get 
> it to work if
> > you pass all the env variables using daemontools and just 
> launch java.
> > However, since java is not a normal daemon, you will probably need
> > fghack to do it. 
> > 
> > I myself gave up; the thought of creating all those environment
> > variables was just too much, so I just rolled my own PID 
> monitor whcih I
> > am porting to Tomcat. Basically, it will grep out the PID 
> and write to a
> > file which I watch with a cronjob process.
> 
> I'b be interested to see that Ben - one of the problems I had 
> trying something
> similar was that when tomcat gets swapped out, it appears on 
> the process list
> as [java] and there is *no way* to my knowledge (or that of 
> the various usenet
> groups/lists etc that I pestered) of getting back the command 
> line to see which
> instance of the JVM you are dealing with - this was a problem 
> for me on a
> machine running at least two JVMs.
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to