[英]Heroku how to setup resque web on a rails 3 app?
I have followed some guides on how to setup resque on heroku, but they are out dated. 我遵循了一些有关如何在heroku上设置resque的指南,但是它们已经过时了。
My config.ru: 我的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: 在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: 我已将此添加到我的gemfile中:
gem "resque"
Then in initalizers/resque.rb: 然后在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. 我正在使用redistogo nano heroku插件。
On Heroku the app crashed with the error: 在Heroku上,应用程序因错误而崩溃:
/app/config.ru:16:in `block (2 leve
ls) in <main>': uninitialized constant Rails::Rack::Static (NameError)
The rails version is 3.2.11
rails版本是3.2.11
It's not able to find the constant Static
in the namespace Rails::Rack
. 在命名空间Rails::Rack
找不到常量Static
。
Try Rack::Static
试试Rack::Static
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.