Re: [jruby-user] Gracefully shutting down JRuby app on Tomcat

Christian MICHON <[email protected]> Thu, 2 Apr 2015 08:01:45 +0200
Newsgroups gmane.comp.lang.jruby.user
Message-ID <CACx2yF-8nCB8qWO2WwXYkBk8r_nStvkY-1oxnUYY2Qg_pD-+jQ@mail.gmail.com>
--f46d0444e9870ab5e30512b791fd
Content-Type: text/plain; charset=UTF-8

Why does your app shut down in the first place? Do you have a logger or a
backtrace in place?

On Wed, Apr 1, 2015 at 9:02 PM, Jose Rosado <[email protected]> wrote:

> Currently I have a large JRuby application running on Tomcat. I have
> generic scripts for managing my tomcat applications. However, my JRuby
> app shuts down before all the currently running requests are done. So
> I'm trying to get my app to wait them to finish before terminating.
>
> My thoughts so far:
> 1) Trap the "TERM" signal with "Signal.trap"
> 2) Respond to load balancer to give the server no more traffic
> 3) ??? Wait for remaining request threads to finish responding
> 4) Normal cleanup in "at_exit"
>
> The problem I have is with #3. I'm having difficulty trying to figure
> out if there are any web requests still processing. I can see here
> (http://wiki.apache.org/tomcat/FAQ/Monitoring) that there are some
> useful JMX beans I could use but I don't know how to import the classes
> (How does "Catalina: type=ThreadPool,name="[depends]"" translate to a
> java_import?). Hell, even after figuring out how to get in the bean I'm
> going to have to play around to see if I can get the information I need
> (Get the active thread count, but does it include everything not just
> request threads? Am I going to have to iterate and check the information
> for each thread? etc.).
>
> Any suggestions? Perhaps I'm going about this the completely wrong way.
>
> Version info: Java 6; JRuby 1.67; Ruby 1.8.7
>
> Thanks!
> Jose
>
> --
> Posted via http://www.ruby-forum.com/.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>


-- 
Christian

--f46d0444e9870ab5e30512b791fd
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Why does your app shut down in the first place? Do you hav=
e a logger or a backtrace in place?</div><div class=3D"gmail_extra"><br><di=
v class=3D"gmail_quote">On Wed, Apr 1, 2015 at 9:02 PM, Jose Rosado <span d=
ir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">li=
[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quot=
e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">=
Currently I have a large JRuby application running on Tomcat. I have<br>
generic scripts for managing my tomcat applications. However, my JRuby<br>
app shuts down before all the currently running requests are done. So<br>
I&#39;m trying to get my app to wait them to finish before terminating.<br>
<br>
My thoughts so far:<br>
1) Trap the &quot;TERM&quot; signal with &quot;Signal.trap&quot;<br>
2) Respond to load balancer to give the server no more traffic<br>
3) ??? Wait for remaining request threads to finish responding<br>
4) Normal cleanup in &quot;at_exit&quot;<br>
<br>
The problem I have is with #3. I&#39;m having difficulty trying to figure<b=
r>
out if there are any web requests still processing. I can see here<br>
(<a href=3D"http://wiki.apache.org/tomcat/FAQ/Monitoring" target=3D"_blank"=
>http://wiki.apache.org/tomcat/FAQ/Monitoring</a>) that there are some<br>
useful JMX beans I could use but I don&#39;t know how to import the classes=
<br>
(How does &quot;Catalina: type=3DThreadPool,name=3D&quot;[depends]&quot;&qu=
ot; translate to a<br>
java_import?). Hell, even after figuring out how to get in the bean I&#39;m=
<br>
going to have to play around to see if I can get the information I need<br>
(Get the active thread count, but does it include everything not just<br>
request threads? Am I going to have to iterate and check the information<br=
>
for each thread? etc.).<br>
<br>
Any suggestions? Perhaps I&#39;m going about this the completely wrong way.=
<br>
<br>
Version info: Java 6; JRuby 1.67; Ruby 1.8.7<br>
<br>
Thanks!<br>
<span class=3D"HOEnZb"><font color=3D"#888888">Jose<br>
<br>
--<br>
Posted via <a href=3D"http://www.ruby-forum.com/" target=3D"_blank">http://=
www.ruby-forum.com/</a>.<br>
<br>
---------------------------------------------------------------------<br>
To unsubscribe from this list, please visit:<br>
<br>
=C2=A0 =C2=A0 <a href=3D"http://xircles.codehaus.org/manage_email" target=
=3D"_blank">http://xircles.codehaus.org/manage_email</a><br>
<br>
<br>
</font></span></blockquote></div><br><br clear=3D"all"><div><br></div>-- <b=
r><div class=3D"gmail_signature">Christian<br></div>
</div>

--f46d0444e9870ab5e30512b791fd--