https://bz.apache.org/bugzilla/show_bug.cgi?id=60632

Jeff Turner <j...@redradishtech.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
             Status|RESOLVED                    |REOPENED

--- Comment #6 from Jeff Turner <j...@redradishtech.com> ---
Konstantin, thanks for reviewing. You caused me to test and think it over some
more. This patch is indeed useless, and should be removed (sorry Mark!).

The reasons are:

- This patch doesn't help for logs generated by Java/Tomcat/webapps (I thought
it would, but never actually tested). That's because 'catalina.sh run' calls
'exec', which replaces the entire bash process, and so the trap is never
called. Besides which, it seems that the worry of systemd losing Java output is
theoretical, at least on my system. In practice JVM shutdown is sufficiently
slow that all output, even from shutdown hooks, is actually caught by systemd
[1].

- Making the delay opt-in means most systemd users won't benefit from it
automatically. If something must be explicitly done, why not, as Konstantin
points out, apply the workaround directly in the systemd service file:

ExecStart=/bin/sh -c '/tmp/apache-tomcat-8.5.11/bin/catalina.sh run; sleep 0.1'


Regards,
Jeff


[1] To verify that the last Java stdout is actually caught by systemd:

cd /tmp
cat > PrintExit.java <<EOF
public class PrintExit {
        public static void main(String[] args) throws Throwable {

                Runtime.getRuntime().addShutdownHook(new Thread() {
                        public void run() {
                                System.out.println("This is the very last thing
printed before shutdown"); 
                        }
                });
                java.util.concurrent.TimeUnit.MINUTES.sleep(1000);
                System.out.println("Application Terminating ...");
        }
}
EOF
javac PrintExit.java
cat > /etc/systemd/system/printexit.service <<EOF
[Service]
Type=simple
User=root
WorkingDirectory=/tmp
ExecStart=/usr/bin/java PrintExit
EOF
systemctl daemon-reload
journalctl -u printexit -f &
systemctl start printexit
# Feb 15 14:32:27 jturner-desktop systemd[1]: Started printexit.service.
systemctl stop printexit
# Feb 15 14:32:30 jturner-desktop systemd[1]: Stopping printexit.service...
# Feb 15 14:32:30 jturner-desktop java[30981]: This is the very last thing
printed before shutdown
# Feb 15 14:32:30 jturner-desktop systemd[1]: printexit.service: Main process
exited, code=exited, status=143/n/a
# Feb 15 14:32:30 jturner-desktop systemd[1]: Stopped printexit.service.
# Feb 15 14:32:30 jturner-desktop systemd[1]: printexit.service: Unit entered
failed state.
# Feb 15 14:32:30 jturner-desktop systemd[1]: printexit.service: Failed with
result 'exit-code'.


(In reply to Konstantin Kolinko from comment #5)
> Re: r1782805
>

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to