我有一个简单的Rails应用程序部署到Heroku Cedar堆栈。
该应用程序使用Resque,并且Resque Sinatra前端应用程序已挂载,因此我可以监控队列:
# routes.rb
...
mount Resque::Server, :at => "/resque"这很有效,但是当部署到Heroku时,Resque front-end's CSS & JavaScript并没有得到服务。
Heroku的日志片段表明它返回的是零字节:
...
2011-07-13T16:19:35+00:00 heroku[router]: GET myapp.herokuapp.com/resque/style.css dyno=web.1 queue=0 wait=0ms service=3ms status=200 bytes=0
2011-07-13T16:19:35+00:00 app[web.1]:
2011-07-13T16:19:35+00:00 app[web.1]:
2011-07-13T16:19:35+00:00 app[web.1]: Started GET "/resque/style.css" for 87.xx.xx.xx at 2011-07-13 16:19:35 +0000
2011-07-13T16:19:35+00:00 app[web.1]: cache: [GET /resque/style.css] miss如何让它为这些资产提供服务?
发布于 2011-07-14 06:51:39
尝试删除路由并将应用程序挂载到config.ru中。我使用的内容大致如下:
require ::File.expand_path('../config/environment', __FILE__)
require 'resque/server'
run Rack::URLMap.new(
"/" => Rails.application,
"/resque" => Resque::Server.new
)发布于 2011-07-14 11:14:20
与ezkl相同,但受密码保护,适用于我:
# config.ru
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require 'resque/server'
# Set the AUTH env variable to your basic auth password to protect Resque.
AUTH_PASSWORD = ENV['RESQUE_PASSWORD']
if AUTH_PASSWORD
Resque::Server.use Rack::Auth::Basic do |username, password|
password == AUTH_PASSWORD
end
end
run Rack::URLMap.new \
'/' => MyApp::Application,
'/resque' => Resque::Server.new发布于 2011-07-14 05:38:15
我认为在部署到heroku时,有必要设置根路径。例如,我通过指定以下命令启动sinatra应用程序
require './app'
run ExampleApp在config.ru中,并在app.rb中设置根目录,如下所示:
class ExampleApp < Sinatra::Base
set :root, File.dirname(__FILE__)
end对我来说,这解决了sinatra应用程序中不支持静态资产的问题。对于resque,也许你可以扩展这个类并挂载它,设置根目录?
https://stackoverflow.com/questions/6682265
复制相似问题