Skip to content
Browse files

Adds Resque

  • Loading branch information...
1 parent 3e44a75 commit a6161373605778dd38cddb4fe97d2a73b8ca5455 @wasabhi wasabhi committed Jul 26, 2012
Showing with 53 additions and 7 deletions.
  1. +1 −0 .env.example
  2. +1 −0 Gemfile
  3. +12 −0 Gemfile.lock
  4. +2 −0 Procfile
  5. +11 −0 Rakefile
  6. +6 −2 config.ru
  7. +0 −5 rea.rb
  8. +20 −0 resque-example-app.rb
View
1 .env.example
@@ -1 +1,2 @@
RACK_ENV=development
+REDISTOGO_URL=redis://localhost:6379/
View
1 Gemfile
@@ -2,6 +2,7 @@ source :rubygems
gem 'rake'
gem 'sinatra'
+gem 'resque'
group :development, :test do
gem 'pry'
View
12 Gemfile.lock
@@ -4,6 +4,7 @@ GEM
coderay (1.0.7)
diff-lcs (1.1.3)
method_source (0.8)
+ multi_json (1.3.6)
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
@@ -14,6 +15,14 @@ GEM
rack-test (0.6.1)
rack (>= 1.0)
rake (0.9.2.2)
+ redis (3.0.1)
+ redis-namespace (1.2.0)
+ redis (~> 3.0.0)
+ resque (1.21.0)
+ multi_json (~> 1.0)
+ redis-namespace (~> 1.0)
+ sinatra (>= 0.9.2)
+ vegas (~> 0.1.2)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
@@ -28,6 +37,8 @@ GEM
tilt (~> 1.3, >= 1.3.3)
slop (3.3.2)
tilt (1.3.3)
+ vegas (0.1.11)
+ rack (>= 1.0.0)
PLATFORMS
ruby
@@ -36,5 +47,6 @@ DEPENDENCIES
pry
rack-test
rake
+ resque
rspec
sinatra
View
2 Procfile
@@ -1 +1,3 @@
web: bundle exec rackup config.ru -p $PORT
+resque-web: bundle exec resque-web --foreground
+resque: bundle exec rake jobs:work
View
11 Rakefile
@@ -0,0 +1,11 @@
+require 'bundler/setup'
+Bundler.require(:default)
+
+require './resque-example-app'
+require 'resque/tasks'
+
+task "resque:setup" do
+ ENV['QUEUE'] = '*'
+end
+
+task "jobs:work" => "resque:work"
View
8 config.ru
@@ -1,2 +1,6 @@
-require './rea.rb'
-run Sinatra::Application
+require './resque-example-app.rb'
+require 'resque/server'
+
+run Rack::URLMap.new \
+ "/" => Sinatra::Application,
+ "/resque" => Resque::Server.new
View
5 rea.rb
@@ -1,5 +0,0 @@
-require 'sinatra'
-
-get '/' do
- "Hello...world..."
-end
View
20 resque-example-app.rb
@@ -0,0 +1,20 @@
+require 'bundler/setup'
+Bundler.require(:default)
+
+module PopString
+ @queue = :puts
+
+ def self.perform(str)
+ puts "Received #{str}"
+ end
+end
+
+configure do
+ uri = URI.parse(ENV["REDISTOGO_URL"])
+ Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
+end
+
+get '/pop/:str' do
+ Resque.enqueue(PopString, params['str'])
+ puts "Popping #{params['str']} onto the queue..."
+end

0 comments on commit a616137

Please sign in to comment.
Something went wrong with that request. Please try again.