On 10/14/2014 10:09 AM, Léa Massiot wrote:
Hello Dan and thank you for your answer.

I installed the JSVC tool as indicated in your document
http://tomcat.apache.org/tomcat-7.0-doc/setup.html#Unix_daemon

I copied the "jsvc" executable into "/opt/tomcat7/bin/".

I also copied "/opt/tomcat7/bin/daemon.sh" into "/etc/init.d" and renamed it
as "tomcat7".

I added the following lines at the beginning of "/etc/init.d/tomcat7":
-------------------------------------------------------------------------
CATALINA_HOME=/opt/tomcat7
export CATALINA_HOME
TOMCAT_USER=webadmin
export TOMCAT_USER
JAVA_HOME=/opt/jdk1.7.0_67
-------------------------------------------------------------------------

I hope I did all this the right way... ?

Now, if I reboot, log in as root and launch the command:
root> ps aux | grep tomcat7

I notice that there are two "jsvc.exec" processes, one run by "root" and the
other one run by "webadmin" which UID is 1000:

The root process forks the child process and then sticks around. You'll see why below.


-------------------------------------------------------------------------
root      2841  0.0  0.0  16752   412 ?        Ss   16:30   0:00 jsvc.exec
-java-home /opt/jdk1.7.0_67 -user webadmin -pidfile
/opt/tomcat7/logs/catalina-daemon.pid -wait 10 -outfile
/opt/tomcat7/logs/catalina-daemon.out -errfile &1 -classpath
/opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/commons-daemon.jar:/opt/tomcat7/bin/tomcat-juli.jar
-Djava.util.logging.config.file=/opt/tomcat7/conf/logging.properties
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.endorsed.dirs= -Dcatalina.base=/opt/tomcat7
-Dcatalina.home=/opt/tomcat7 -Djava.io.tmpdir=/opt/tomcat7/temp
org.apache.catalina.startup.Bootstrap

1000      2842  8.9  1.1 2434512 97444 ?       Sl   16:30   0:03 jsvc.exec
-java-home /opt/jdk1.7.0_67 -user webadmin -pidfile
/opt/tomcat7/logs/catalina-daemon.pid -wait 10 -outfile
/opt/tomcat7/logs/catalina-daemon.out -errfile &1 -classpath
/opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/commons-daemon.jar:/opt/tomcat7/bin/tomcat-juli.jar
-Djava.util.logging.config.file=/opt/tomcat7/conf/logging.properties
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.endorsed.dirs= -Dcatalina.base=/opt/tomcat7
-Dcatalina.home=/opt/tomcat7 -Djava.io.tmpdir=/opt/tomcat7/temp
org.apache.catalina.startup.Bootstrap
-------------------------------------------------------------------------

If I "kill -9" the process owned by user 1000, another process is
immediately created to replace the killed one.

The parent process which runs as ROOT re-starts the child process if it accidentally dies. So, if you have a segfault, your app gets re-started.


If I kill the process owned by "root", no new process is created.
And if I kill the last remaining process, the one owned by user 1000, no new
process is created either.

That's expected.

I noticed that the $CATALINA_PID file contain the PID of the process owned
by user 1000.

Which is the UID of your webadmin user that you specified on the command line to jsvc.

I am wondering if this is normal behavior and if it is, why is it behaving
like this?

It's behaving that way by design. If you stop and think about what it's doing, it makes perfect sense.

If you want to shut the app down, you need to use the JSVC executable to do so, or do a "killall -9 jsvc".

--
George Sexton
*MH Software, Inc.*
Voice: 303 438 9585
http://www.mhsoftware.com

Reply via email to