I have followed some guides on how to setup resque on heroku, but they are out dated.
My config.ru:
require File.dirname(__FILE__) + '/config/environment'
require 'resque/server'
Resque::Server.class_eval do
use Rack::Auth::Basic do |email, password|
user = User.authenticate( email, password )
user && user.admin?
end
end
app = Rack::Builder.new {
use Rails::Rack::Static
map "/resque" do
run Resque::Server
end
map "/" do
run ActionController::Dispatcher.new
end
}.to_app
run app
In lib/tasks/resque.task:
require 'resque/tasks'
task "resque:setup" => :environment do
ENV['QUEUE'] = '*'
end
desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"
I have added this to my gemfile:
gem "resque"
Then in initalizers/resque.rb:
ENV["REDISTOGO_URL"] ||= "mydatabaseurl"
uri = URI.parse(ENV["REDISTOGO_URL"])
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password, :thread_safe => true)
I am using to redistogo nano heroku addon.
On Heroku the app crashed with the error:
/app/config.ru:16:in `block (2 leve
ls) in <main>': uninitialized constant Rails::Rack::Static (NameError)
The rails version is 3.2.11
It's not able to find the constant Static
in the namespace Rails::Rack
.
Try Rack::Static
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.