service tomcat7 start fails, but the process exists and tomcat is running

后端 未结 4 2042
名媛妹妹
名媛妹妹 2021-02-19 10:29

I have been trying to install tomcat7 on ubuntu docker images with apt-get install tomcat7. The installation works fine and starting tomcat from the catalina.sh wo

相关标签:
4条回答
  • 2021-02-19 11:00

    Docker does not start up any of the OS services, only the command given in the Dockerfile or explicitly on the command line.

    My understanding is that service and related commands depend on an init process which does not exist.

    You should start you tomcat explicitly from the Catalina scripts. You can wrap that with something like supervisord to get the "restart-if-it-crashes" behavior.

    0 讨论(0)
  • 2021-02-19 11:08

    In the docker Ubuntu image I am using (5506de2b643b - 14.04.1 LTS), the start-stop-daemon with the --test argument is working incorrectly and reports that tomcat is not running, even when it is.

    The tomcat7 init.d script starts tomcat because start-stop-daemon --test says (correctly) tomcat is not running, but then a little later in the startup process it checks that tomcat started successfully and is running. start-stop-daemon --test now incorrectly says tomcat is not running, which causes the tomcat7 init.d script to remove the PID file.

    As a result, service tomcat7 status returns false when tomcat is running because the PID file is gone, but it will return false even if the PID file is there with correct PID due to the bug in start-stop-daemon --test.

    Here's an example session demonstrating the bug:

    #TOMCAT PID IS 43
    root@a2cf26ade2a9:/# ps -eaf | grep tomcat7
    tomcat7     43     1  0 14:06 ?        00:00:04 /usr/lib/jvm/java-7-oracle/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.Bootstrap start
    
    #PID FILE HAS CORRECT PID
    root@a2cf26ade2a9:/#  cat /var/run/tomcat7.pid
    43
    
    #START-STOP-DAEMON --TEST REPORTS THAT IT WOULD START TOMCAT
    root@a2cf26ade2a9:/#  start-stop-daemon --test --start --pidfile /var/run/tomcat7.pid --user tomcat7 --exec /usr/lib/jvm/java-7-oracle/bin/java
    Would start /usr/lib/jvm/java-7-oracle/bin/java .
    
    root@a2cf26ade2a9:/# echo $?
    0
    
    0 讨论(0)
  • 2021-02-19 11:12

    I encountered this. I fixed it (finally) by adding JAVA_HOME=/usr/lib/jvm/java-8-oracle to /etc/default/tomcat7. For some reason it was using that JAVA_HOME to actually run the process, but it was using /usr/lib/jvm/default-java to check if the process was running. This confused it, so it never detected that the process was running.

    0 讨论(0)
  • 2021-02-19 11:12

    I happens have the some situation, it caused by deleting /var/lib/tomcat7/logs directory, where I remake the directory, it owned by another user, so that tomcat7 can not restart, and not logs output, I change own, now it works fine.

    sudo chown tomcat7.tomcat7 /var/log/tomcat7
    sudo chown tomcat7.tomcat7 /var/lib/tomcat7/logs
    
    0 讨论(0)
提交回复
热议问题