Heroku Cedar - 没有安装 Resque 前端的静态资源
我有一个简单的 Rails 应用程序部署到 Heroku Cedar 堆栈。
该应用程序使用 Resque,并且安装了 Resque Sinatra 前端应用程序,以便我可以监控队列:
# routes.rb
...
mount Resque::Server, :at => "/resque"
这很好用,但是当部署到 Heroku 时,Resque 前端的 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
如何让它为这些资产提供服务?
I have a simple Rails app deployed to the Heroku Cedar stack.
The app uses Resque and the Resque Sinatra front-end app is mounted so I can monitor the queue:
# routes.rb
...
mount Resque::Server, :at => "/resque"
This works great, but when deployed to Heroku, the Resque front-end's CSS & JavaScript are not being served.
A snippet of Heroku's logs indicates it's returning zero bytes:
...
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
How can I get it to serve these assets?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试删除路由并将应用程序安装到
config.ru
中。我正在使用类似的东西:Try removing the route and mounting the app in your
config.ru
. I'm using something along the lines of:与 ezkl 相同,但受密码保护,对我有用:
Same as ezkl but password protected, works for me:
我认为部署到heroku 时有必要设置根路径。例如,我通过在
config.ru
中指定来启动 sinatra 应用程序并在
app.rb
中设置根目录:, 对我来说是一个 sinatra 应用程序。
对于 resque,也许您可以扩展该类并安装它,设置根?
I believe it's necessary to set a root path, when deploying to heroku. For example, I boot a sinatra application by specifying
in
config.ru
, and setting the root inapp.rb
thus:That solves the problem of static assets not being served in a sinatra application, for me.
For resque, perhaps you can extend the class and mount that instead, setting the root?
HEROKU Cedar stack 和rescue 需要这行代码来防止数据库连接失败。
上面的代码应该放在:
/lib/tasks/resque.rake
例如:
希望这对某人有帮助,就像它对我一样。
HEROKU Cedar stack and rescue need this line of code to prevent database connection failure.
Above code should be placed in:
/lib/tasks/resque.rake
For example:
Hope this helps someone, as much as it did for me.