Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 81E19105A8 for ; Tue, 15 Oct 2013 16:25:41 +0000 (UTC) Received: (qmail 85539 invoked by uid 500); 15 Oct 2013 16:24:51 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 85476 invoked by uid 500); 15 Oct 2013 16:24:48 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 85321 invoked by uid 99); 15 Oct 2013 16:24:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Oct 2013 16:24:47 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [76.96.59.228] (HELO qmta15.westchester.pa.mail.comcast.net) (76.96.59.228) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Oct 2013 16:24:41 +0000 Received: from omta05.westchester.pa.mail.comcast.net ([76.96.62.43]) by qmta15.westchester.pa.mail.comcast.net with comcast id dP8c1m0020vyq2s5FUQLVi; Tue, 15 Oct 2013 16:24:20 +0000 Received: from Christophers-MacBook-Pro.local ([69.143.106.98]) by omta05.westchester.pa.mail.comcast.net with comcast id dUQL1m00927QCxh3RUQLeH; Tue, 15 Oct 2013 16:24:20 +0000 Message-ID: <525D6C3D.2050004@christopherschultz.net> Date: Tue, 15 Oct 2013 12:24:29 -0400 From: Christopher Schultz User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: ProcessBuilder and waitFor prevents tomcat to continue References: <009c01cec916$d17348e0$7459daa0$@tosovsky@email.cz> In-Reply-To: <009c01cec916$d17348e0$7459daa0$@tosovsky@email.cz> X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1381854260; bh=yVbestp9TYQ5G4IkQvK+cLNoeiplZ6pUWO+rygAmuqc=; h=Received:Received:Message-ID:Date:From:MIME-Version:To:Subject: Content-Type; b=FhfWui/zSgM9rkvVPNZSanPHTntuFdRCy5mCvKUy45Sov9KQBOSHKNtNpSQ6UOoGO df1G0Sb4wbIirvv9vigQTXeGXfO8+wF6u+OAfU++fwrkmq0G3RVwcvM1dBTB4tfjud LCLzVZZQ6p3b8kMICGQjxDcB4D6Zx9n9Qxyo4rpRx9mvXfGcAuEH1PyuKOg3tXMtq0 u3djADt6Rpe70wgw4vAneIgRLg7JT061vDVBsvcoCiv+PL6oXClr0ocNBUKJ9ekuXD Q2K1/b5xO374KjxoI4QcuKdeWA2C43zkgRUojjNkMDAElhtcR41R2iOMJcQTcXONhj aYMSjgyujCE/w== X-Virus-Checked: Checked by ClamAV on apache.org -----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