Rails 3 runner with .war deployment

Hi,

I’m trying to figure out how to run a ‘rails runner’-type task (for a
cron job) with a .war-file deployment of a rails 3 app?

Perhaps something like this:

export RAILS_ENV=production
export
CLASSPATH=/opt/tomcat7/webapps/ROOT/WEB-INF/lib/jruby-core-1.6.3.jar:/opt/tomcat7/webapps/ROOT/WEB-INF/lib/jruby-rack-1.0.9.jar:/opt/tomcat7/webapps/ROOT/WEB-INF/lib/jruby-stdlib-1.6.3.jar
export GEM_PATH=/opt/tomcat7/webapps/ROOT/WEB-INF/gems
java org.jruby.Main -w -S rails runner “MyModel.run_nightly_report”

?

Thanks,

Brian

On Oct 10, 2011, at 8:21 PM, Brian Olpin wrote:

export GEM_PATH=/opt/tomcat7/webapps/ROOT/WEB-INF/gems
java org.jruby.Main -w -S rails runner “MyModel.run_nightly_report”

?

Not exactly what you’re looking for, but I’ve been using the following
script to run the Rails console from inside an exploded .war. I’m sure
it would something similar for the rails runner.

From inside a deployed WEB-INF directory I run script/tomcat-console

-lenny

On Oct 11, 2011, at 10:45 AM, Lenny M. wrote:

export RAILS_ENV=production

From inside a deployed WEB-INF directory I run script/tomcat-console

-lenny

Actually, the gist above works for all rails commands if you just remove
the line ARGV.unshift(‘c’) line and run it like:

cd WEB-INF
script/tomcat-rails console
script/tomcat-rails runner myscript.rb

-lenny