Loading environment in script started with StartupScriptLauncher and jruby-rack 0.9.5

Hello,

I am trying to run a script at rails startup from a war file using the
StartupScriptLauncher listener class written by Nick Seiger:

I have seen a couple of examples of its use on the web. Both use the
following code in the config/startup.rb script to load the rails
environment:

require ‘jruby/rack/rails’
JRuby::Rack::RailsServletHelper.instance.load_environment

This was not working for me, and I realized looking the the jruby-rack
code that RailsServletHelper has been replaced by RailsBooter in
version 0.9.5. From the jruby-rack code, it looks like replacing that
line with

JRuby::Rack.booter.load_environment

should work, but JRuby::Rack.booter is nil inside the startup script.
Does anyone know how to load the the environment in 0.9.5?

Thanks,
Jesse R.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Jesse,

Try the following additional require below to initialize the booter.

Cheers,
/Nick

On Thu, Oct 1, 2009 at 5:36 PM, Jesse R. [email protected]
wrote:

require ‘jruby/rack/rails’
require ‘jruby/rack/boot/rails’

Does anyone know how to load the the environment in 0.9.5?


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Thanks for the response. I needed the require, but that didn’t get me
the whole way there. The call to load_environment failed because
@layout was not initialized for the booter. I added a call to boot!,
and then it started working. Here is the full listing for loading the
environment:

require ‘jruby/rack/rails’
require ‘jruby/rack/boot/rails’
JRuby::Rack.booter.boot!
JRuby::Rack.booter.load_environment

Thanks again,
Jesse

On Thu, Oct 1, 2009 at 11:05 PM, Nick S. [email protected]
wrote:

I am trying to run a script at rails startup from a war file using the
JRuby::Rack::RailsServletHelper.instance.load_environment


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email