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
bolpin
October 11, 2011, 4:46pm
2
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.
gistfile1.rb
#!/usr/bin/env jruby
raise "Must specify CATALINA_HOME" unless ENV['CATALINA_HOME']
ENV['GEM_HOME'] ||= File.expand_path('../../gems', __FILE__)
require File.expand_path('../../../META-INF/init', __FILE__)
# expected by rails/commands
APP_PATH = File.expand_path('../../config/application', __FILE__)
This file has been truncated. show original
From inside a deployed WEB-INF directory I run script/tomcat-console
-lenny
bolpin
October 11, 2011, 4:59pm
3
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