Heroku Cedar - no static assets for mounted Resque front-end

十年热恋 提交于 2019-12-05 06:09:46

Try removing the route and mounting the app in your config.ru. I'm using something along the lines of:

require ::File.expand_path('../config/environment',  __FILE__)
require 'resque/server'

run Rack::URLMap.new(
    "/" => Rails.application,
    "/resque" => Resque::Server.new 
)

Same as ezkl but password protected, works for me:

# 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

I believe it's necessary to set a root path, when deploying to heroku. For example, I boot a sinatra application by specifying

require './app'
run ExampleApp

in config.ru, and setting the root in app.rb thus:

class ExampleApp < Sinatra::Base
  set :root, File.dirname(__FILE__)
end

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?

user1194708

HEROKU Cedar stack and rescue need this line of code to prevent database connection failure.

Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }

Above code should be placed in: /lib/tasks/resque.rake

For example:

require 'resque/tasks'

task "resque:setup" => :environment do
  ENV['QUEUE'] = '*'

  Resque.after_fork do |job|
    ActiveRecord::Base.establish_connection
  end

end

desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"

Hope this helps someone, as much as it did for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!