Created
March 7, 2010 06:03
-
-
Save skippy/324196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails::Initializer.run do |config| | |
#....... | |
config.middleware.use 'ResqueWeb' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
class ResqueWeb < Sinatra::Base | |
require 'resque/server' | |
use Rack::ShowExceptions | |
# Set the AUTH env variable to your basic auth password to protect Resque. | |
AUTH_PASSWORD = ENV['AUTH'] | |
if AUTH_PASSWORD | |
Resque::Server.use Rack::Auth::Basic do |username, password| | |
password == AUTH_PASSWORD | |
end | |
end | |
def call(env) | |
if env["PATH_INFO"] =~ /^\/resque/ | |
env["PATH_INFO"].sub!(/^\/resque/, '') | |
env['SCRIPT_NAME'] = '/resque' | |
app = Resque::Server.new | |
app.call(env) | |
else | |
super | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This really helped me out. Thanks!