Hi,
instead of deploying war-files I use a little Ruby script which spawns the
Jetty server objects including JRuby-Rack. While this worked without any
problems with Goldspike there are a few issues with JRuby-Rack:

1) I didn't manage to point "rails.root" to the right place (gets screwed up
by some internal processing of the path). Therefore I patched rails.rb to
accept a "rails.root_absolute" parameter which is used without any further
treatment in case it exists.

2) I added a few lines of Java code to RackServletContextListener to be able
to detect if errors happened during startup. In case of an error I simply
want to shutdown the whole server/JVM.

3) I also added a config param to disable using the servlet context's logger
and keep the default Rails logger.


I've attached the diffs. Should I create a Jira issue or are there any other
solutions for my problems?

Christian
Index: src/main/java/org/jruby/rack/RackServletContextListener.java
===================================================================
--- src/main/java/org/jruby/rack/RackServletContextListener.java        
(revision 235)
+++ src/main/java/org/jruby/rack/RackServletContextListener.java        
(working copy)
@@ -17,6 +17,7 @@
 public class RackServletContextListener implements ServletContextListener {
     public static final String FACTORY_KEY = "rack.factory";
     private final RackApplicationFactory factory;
+    private String errorMsg;
 
     public RackServletContextListener() {
         factory = null;
@@ -38,6 +39,7 @@
             fac.init(ctx);
         } catch (Exception ex) {
             ctx.log("Error: application initialization failed", ex);
+            this.errorMsg = ex.toString();
         }
     }
 
@@ -58,4 +60,8 @@
 
         return new SharedRackApplicationFactory(new 
DefaultRackApplicationFactory());
     }
+
+    public String getErrorMsg() {
+        return errorMsg;
+    }
 }
\ No newline at end of file
Index: src/main/ruby/jruby/rack/rails.rb
===================================================================
--- src/main/ruby/jruby/rack/rails.rb   (revision 235)
+++ src/main/ruby/jruby/rack/rails.rb   (working copy)
@@ -16,6 +16,7 @@
         @rails_root = @servlet_context.getInitParameter 'rails.root'
         @rails_root ||= '/WEB-INF'
         @rails_root = expand_root_path @rails_root
+        @rails_root = @servlet_context.getInitParameter('rails.root_absolute') 
unless @servlet_context.getInitParameter('rails.root_absolute').nil?
         @rails_env = @servlet_context.getInitParameter 'rails.env'
         @rails_env ||= 'production'
         ENV['RAILS_ROOT'] = @rails_root
@@ -78,6 +79,8 @@
       end
 
       def setup_logger
+        return if @servlet_context.getInitParameter('logger.keep_default') == 
'true'
+
         if defined?(::RAILS_DEFAULT_LOGGER)
           class << ::RAILS_DEFAULT_LOGGER # Make these accessible to wire in 
the log device
             public :instance_variable_get, :instance_variable_set
@@ -157,4 +160,4 @@
       end
     end
   end
-end
\ No newline at end of file
+end
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to