我一直在运行带有rackup config.ru文件的rails 2.3应用程序来加载一些葡萄API中间件。
我最近需要运行resque服务器。
我的config.ru设置如下。
require File.dirname(__FILE__) + '/config/environment'
my_app = Rack::Builder.new do
use Rails::Rack::LogTailer #optional
use Rails::Rack::Static # optional
run ActionController::Dispatcher.new
end
Resque::Server.class_eval do
use Rack::Auth::Basic do |user, password|
begin
if user == "admin" and password == "bandana"
true
else
false
end
end
end
end
run Rack::URLMap.new([
"/" => my_app,
"/resque" => Resque::Server.new
])
run Rack::Cascade.new([
GrapeAPI_entry_1,
GrapeAPI_entry_2,
my_app
])
这并没有给我预期的效果,我不知道为什么。
答案 0 :(得分:4)
我实际上找到了答案。事实证明redis没有运行,是的,你可以使用cascade with map
我的最终config.ru看起来像这样。
re File.dirname(__FILE__) + '/config/environment'
require 'resque/server'
my_app = Rack::Builder.new do
use Rails::Rack::LogTailer #optional
use Rails::Rack::Static # optional
run ActionController::Dispatcher.new
end
Resque::Server.class_eval do
use Rack::Auth::Basic do |user, password|
begin
if user == "admin" and password == "bandana"
true
else
false
end
end
end
end
app = Rack::Builder.new {
use Rails::Rack::Static
map "/resque" do
run Resque::Server
end
map "/" do
run my_app
end
}.to_app
run Rack::Cascade.new([
Grape_API_1,
Grape_API_2,
my_app
])
答案 1 :(得分:1)
我最近在我的一个rails服务器上添加了类似的resque访问权限。它很棒 - 这就是我做的方式:
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require 'resque/server'
run Rack::URLMap.new \
"/" => MyApp::Application,
"/resque" => Resque::Server.new
我的应用程序基于rails 3.2。我不确定你正在运行的机架版本有什么不同。
您是否需要resque服务器代码?