Title: [645] trunk/rails-integration: support for a small wait in task servlet to support staggering start ups of background tasks
Revision
645
Author
tirsen
Date
2007-06-20 05:19:08 -0400 (Wed, 20 Jun 2007)

Log Message

support for a small wait in task servlet to support staggering start ups of background tasks

Modified Paths

Diff

Modified: trunk/rails-integration/build.xml (644 => 645)


--- trunk/rails-integration/build.xml	2007-06-19 16:13:51 UTC (rev 644)
+++ trunk/rails-integration/build.xml	2007-06-20 09:19:08 UTC (rev 645)
@@ -51,7 +51,7 @@
   </target>
   <target name="compile-tests" depends="junit-present, compile" description="Compile the test code" if="junit.present">
     <mkdir dir="${maven.test.output}"/>
-    <javac destdir="${maven.test.output}" excludes="**/package.html" debug="true" deprecation="true" optimize="false">
+    <javac destdir="${maven.test.output}" excludes="**/package.html" debug="true" deprecation="true" optimize="false" target="1.4" source="1.4">
       <src>
         <pathelement location="src/test/java"/>
       </src>

Modified: trunk/rails-integration/src/main/java/org/jruby/webapp/RailsTaskServlet.java (644 => 645)


--- trunk/rails-integration/src/main/java/org/jruby/webapp/RailsTaskServlet.java	2007-06-19 16:13:51 UTC (rev 644)
+++ trunk/rails-integration/src/main/java/org/jruby/webapp/RailsTaskServlet.java	2007-06-20 09:19:08 UTC (rev 645)
@@ -9,19 +9,26 @@
 import java.io.IOException;
 
 public class RailsTaskServlet extends RailsServlet {
+    private String script;
+    private int waitBeforeStartSeconds = 30; // wait 30 seconds
+    
     public void init(final ServletConfig servletConfig) throws ServletException {
         super.init(servletConfig);
-        final String script = servletConfig.getInitParameter("script");
+        
+        script = servletConfig.getInitParameter("script");
+        String waitBeforeStartSecondsString = servletConfig.getInitParameter("waitBeforeStartSeconds");
+        if(waitBeforeStartSecondsString != null) {
+            waitBeforeStartSeconds = Integer.parseInt(waitBeforeStartSecondsString);
+        }
+        
         new Thread(new Runnable() {
             public void run() {
                 try {
-                    // wait until the pool has more than one rails instance available
+                    // wait for a little while before starting the task
                     // this allow the app server to start serving requests before initializing all tasks
-                    while (getRuntimePool().getNumIdle() <= 2) {
-                        try {
-                            Thread.sleep(5 * 1000);
-                        } catch (InterruptedException ignore) {
-                        }
+                    try {
+                        Thread.sleep(waitBeforeStartSeconds * 1000);
+                    } catch (InterruptedException ignore) {
                     }
 
                     while (true) {
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to