tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: ProcessBuilder and waitFor prevents tomcat to continue
Date Tue, 15 Oct 2013 16:24:29 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Honyk,

On 10/14/13 3:51 PM, honyk wrote:
> my web app executes long running external scripts. It is triggered
> on startup (contextInitialized) and then regularly during the day.

Why do people do this? Cron is great. :(

> When the app server needs to be restarted and this process is
> running, tomcat waits till the process finishes.
> 
> When tomcat is starting, it waits again till processing is finished
> and after that it continues in loading.
> 
> My script is executed via ProcessBuilder with waitFor flag.
> 
> Is it possible: 1) to kill this external process automatically when
> tomcat is shut down?

You can try. Process.destroy(). There is no guarantee that the process
will actually die, or whether it will clean-up properly.

> 2) to execute the script for the first time in any post-init phase?
> By this I mean - my app is initialized so I can access the
> corresponding JSF setting page and in the same time long running
> script is running. Now the page cannot be displayed until process
> finishes.

You can launch the process and forget about it. Or, you can launch the
process in a separate thread and wait for it to complete, there.

> I expect it is rather OT here in tomcat dicussion, but it is quite
> unclear to me what I can expect from the app server here (if it can
> control this somehow or it is solely driven by my web app
> settings).

Most processes in the container are expected to be synchronous (except
- -- somewhat obviously -- for the servlet async stuff). If you need
things to behave differently, then you need to handle asynchronous
operations yourself (with threads).

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSXWw9AAoJEBzwKT+lPKRY4a8P/0dtxyQKlLWy29jdnSOrLBZN
csjkKyzpNhy0roeJZXsAQKTwXZMTYFZoNXnBFRTFQdhXyok1m6L0bT/cx8iQwztp
RCEN9aoIm2s93yZdJzsJWTUeE0XoPFwsOpctakTpjiOQD19L+NnZEyG1+HsdePlN
i+8Cg56usd5ZxVrDkQLdL5AQivq5kTXis4HNw9vWb2YEZRZawIZMs3VBWbUpZbvE
aFOSq75kFfAvbKTzdEZoAkizdt0RnY2jRcYqH3iCySLo5uIWiBWMEWRYS+BDCc4j
aJWVSjW/nNv7OmbULssWuYtV+HSUayHLj+LMb9//0A4VC7MCz0q17LukJsGu1LBB
2x4MWmwGxMP+dnMhGHig36Tk4TTcikYtccpmv2JPwz1/X9siPGJBmc/dq8A/qFE4
35Drk/9SW9zPSHXTUSDEU07R9xz7LxRMkaKOh3tjGDKCpmtGuj09z4MwgfHKC4+p
PhO9IWkd+C7cBeMZU3ENPSuKIekjZhYG2KDOtEYOBUGgm+lUouCrl2Y3vHleV9ip
OHVR+dt68goQu50LT6XN5WsXHYGOB76STuTEXNjQ7wPJAkjq6f8Z/OAybAW7GAmd
KBWRSBEIEU4hICJTlRvr+9rNiG2TLCfymZqLPPf+hEZT0GEcUIw/r8M23M3RDcX9
ArzPZ7Gsjyg37Wonlzcp
=AIWB
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message