我们有两个使用Resque和Redis的Rails应用程序。在两个应用程序上,Resque和Redis的配置都相同,都使用Rails 4.2和Resque 1.27.4。
但是,最好将/resque
路径上的Resque服务器的可用性描述为在两个应用程序中“不平衡”(为简化起见,我将其真实名称简称为“ planning”和“ staffing”)。
rails s
,两个应用程序都会引发路由错误:No route matches [GET] "/resque"
,即使错误页面上的路由列表中最高优先级包括/resque
:resque_server_path /resque Resque::Server
我从哪里开始弄清楚一个地方是正确的而另一个地方是错的?
以下是相关的routes.rb
行(两个应用程序中的所有这些都相同):
mount Resque::Server, :at => '/resque', :constraints => RouteConstraint::Admin
lib/tasks/resque.rake
:
require 'resque/tasks'
task "resque:setup" => :environment do
ENV['QUEUE'] = '*'
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
end
desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"
config/initializers/redis.rb
:
# Cloned from staffing
uri = URI.parse(ENV["REDISTOGO_URL"] || "redis://localhost:6379/")
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
# Tell Resque which redis to use and ensure database connections don't go stale.
Resque.redis = REDIS
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
# load job classes.
Dir["#{Rails.root}/app/jobs/*.rb"].each { |file| require file }
Resque::Plugins::Status::Hash.expire_in = (24 * 60 * 60) # 24hrs in seconds
# https://github.com/resque/resque/wiki/Failure-Backends
require 'resque/failure/multiple'
require 'resque/failure/airbrake'
require 'resque/failure/redis'
Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Airbrake]
Resque::Failure.backend = Resque::Failure::Multiple
[config.ru
在非Resque相关设置中包括此行:
require 'resque/server'
下一步我应该去哪里?
ETA:我尝试通过安装该gem来切换到resque-web,然后像这样更改config/routes.rb
:
require "resque_web"
Rails.application.routes.draw do
mount ResqueWeb::Engine, :at => "/resque", :constraints => RouteConstraint::SuperAdmin
end
((显然,文件还有更多,但end
实际上是文件的顶部。)仍然存在相同的问题:即使路由明确存在,访问/resque
也会引发错误No route matches [GET] "/resque"
。这是rake routes
输出的尾巴:
Routes for ResqueWeb::Engine:
overview GET /overview(.:format) resque_web/overview#show
working_index GET /working(.:format) resque_web/working#index
clear_queue PUT /queues/:id/clear(.:format) resque_web/queues#clear {:id=>/[^\/]+/}
queues GET /queues(.:format) resque_web/queues#index
queue GET /queues/:id(.:format) resque_web/queues#show {:id=>/[^\/]+/}
DELETE /queues/:id(.:format) resque_web/queues#destroy {:id=>/[^\/]+/}
workers GET /workers(.:format) resque_web/workers#index
worker GET /workers/:id(.:format) resque_web/workers#show {:id=>/[^\/]+/}
retry_failure PUT /failures/:id/retry(.:format) resque_web/failures#retry
retry_all_failures PUT /failures/retry_all(.:format) resque_web/failures#retry_all
destroy_all_failures DELETE /failures/destroy_all(.:format) resque_web/failures#destroy_all
failures GET /failures(.:format) resque_web/failures#index
failure GET /failures/:id(.:format) resque_web/failures#show
DELETE /failures/:id(.:format) resque_web/failures#destroy
stats GET /stats(.:format) resque_web/stats#index
stats_resque GET /stats/resque(.:format) resque_web/stats#resque
stats_redis GET /stats/redis(.:format) resque_web/stats#redis
stats_keys GET /stats/keys(.:format) resque_web/stats#keys
keys_statistic GET /stats/keys/:id(.:format) resque_web/stats#keys {:id=>/[^\/]+/}
root GET / resque_web/overview#show
我想知道关于发动机的安装方式吗?或者,如果有什么东西遮挡了路线?