CATALINA_OUT_CMD usage

Asked by dou

Hi,

I would like to use CATALINA_OUT_CMD to pipe stdout/stderr to rotatelogs
like :
CATALINA_OUT_CMD="rotatelogs -l /var/log/tomcat9/catalina.out.instance2.%Y.%m.%d 86400"

1) /usr/libexec/tomcat9/tomcat-start.sh always pass "run" as arg to catalina.sh and so CATALINA_OUT_CMD can't be used
Can we add an test to tomcat-start.sh and use "start" instead of "run" if CATALINA_OUT_CMD is defined maybe ?

I can do the change in /usr/libexec/tomcat9/tomcat-start.sh myself but I'm afraid it will not persist after update/upgrade

2) For testing, after changing tomcat-start.sh (from "run" to "start" ), catalina.sh take CATALINA_OUT_CMD but tomcat is killed by systemd

      eval \{ $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
        -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
        -classpath "\"$CLASSPATH\"" \
        -Dcatalina.base="\"$CATALINA_BASE\"" \
        -Dcatalina.home="\"$CATALINA_HOME\"" \
        -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
        org.apache.catalina.startup.Bootstrap "$@" start \
        2\>\&1 \&\& echo \$! \>\"$catalina_pid_file\" \; \} $catalina_out_command "&"

(If I remove the "&" it start and systemd dont kill the tomcat)

Is passing tomcat to background is always a good idea with systemd ? If not, can we open a bug-report to fix it and where ?

tomcat9 9.0.16-3~18.04.1
tomcat9-common 9.0.16-3~18.04.1

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu tomcat9 Edit question
Assignee:
No assignee Edit question
Solved by:
dou
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

What is the output of:

lsb_release -a; uname -a; apt-cache policy tomcat9 tomcat9-common

Thanks

Revision history for this message
dou (douphi) said :
#2

root@cri-pp1:~# lsb_release -a; uname -a; apt-cache policy tomcat9 tomcat9-common
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
Linux cri-pp1 4.18.0-22-generic #23~18.04.1-Ubuntu SMP Thu Jun 6 08:37:25 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
tomcat9:
  Installé : 9.0.16-3~18.04.1
  Candidat : 9.0.16-3ubuntu0.18.04.1
 Table de version :
     9.0.16-3ubuntu0.18.04.1 500
        500 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/universe i386 Packages
 *** 9.0.16-3~18.04.1 100
        100 /var/lib/dpkg/status
tomcat9-common:
  Installé : 9.0.16-3~18.04.1
  Candidat : 9.0.16-3ubuntu0.18.04.1
 Table de version :
     9.0.16-3ubuntu0.18.04.1 500
        500 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/universe i386 Packages
 *** 9.0.16-3~18.04.1 100
        100 /var/lib/dpkg/status

Revision history for this message
dou (douphi) said :
#3

I just upgraded to latest candidat 9.0.16-3ubuntu0.18.04.1 from bionic-security/universe
but the scripts /usr/share/tomcat9/bin/catalina.sh and /usr/libexec/tomcat9/tomcat-start.sh are the same so I expect the same problem

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#4

If you report a bug with your new file as a fix it may be updated in the package and save having to repeatedly update the file yourself. I don't use Apache / web servers etc but can get good information from users to help more knowledgeable helpers

Revision history for this message
dou (douphi) said :
#5

It seems simplier to handle that part ( | rotatelog ) via systemd and not rely on CATALINA_OUT_CMD from catalina.sh.

With CATALINA_OUT_CMD we must handle to change systemd service from "Type=simple" to "Type=forking" because of "&"
and so, use systemd PIDFile= to have a nice kill of an instance of tomcat ( if multi-instance )
else it will just kill -9 tomcat violently

So I will continue with systemd "Type=simple"
and
ExecStart=/bin/sh -c '/usr/libexec/tomcat9/tomcat-start.sh | /usr/bin/rotatelogs -l /var/log/tomcat9/catalina.out.instance2.%%Y.%%m.%%d 86400'

instead of relaying on CATALINA_OUT_CMD with don't interact well with systemd