我们有两个使用Resque和Redis的Rails应用程序。Resque和Redis在这两个应用程序上的配置是相同的,它们都使用Rails 4.2和Resque 1.27.4。
但是,/resque路径上的Resque服务器的可用性最好被描述为两个应用程序之间的“不均匀”(我将把它们的实名缩短为“计划”和“人员配置”以简化)。
rails s,两个应用程序都会引发路由错误:No route matches [GET] "/resque",尽管错误页面后面的路由列表中包含了以最高优先级排列的/resque:resque_server_path /resque Resque::Server
我从哪里开始弄清楚在一个地方什么是对的,在另一个地方是错的?
下面是相关的routes.rb行(在这两个应用程序中,所有这些都是相同的):
mount Resque::Server, :at => '/resque', :constraints => RouteConstraint::Adminlib/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::Multipleconfig.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我想知道发动机是如何安装的吗?或者,交替地,如果有什么东西在跟踪路线?
发布于 2019-10-18 16:44:14
您应该研究routes.rb文件中定义的路由约束。当约束失败时,它们返回与您所看到的错误一致的404未找到的错误。当你去掉约束时会发生什么?
https://stackoverflow.com/questions/58309431
复制相似问题