Permalink
Browse files

Trying out Sidekiq.

  • Loading branch information...
1 parent 979f3b5 commit 2b536f8a9c3dccba7fde3e1062a2735b4102fc40 @thegreatape committed Nov 5, 2012
View
@@ -7,9 +7,10 @@ gem 'hpricot'
gem 'goodreads', :git => 'git://github.com/thegreatape/goodreads.git', :ref => '762a1487556f'
gem 'oauth'
gem 'dynamic_form'
-gem 'resque', "~> 1.22.0"
-gem 'resque-scheduler'
-gem 'hirefire'
+gem 'sidekiq'
+gem 'sinatra', require: false
+gem 'slim'
+gem 'autoscaler'
gem 'will_paginate'
gem 'thin'
gem 'newrelic_rpm'
View
@@ -42,6 +42,9 @@ GEM
addressable (2.3.2)
ansi (1.4.3)
arel (3.0.2)
+ autoscaler (0.0.2)
+ heroku-api
+ sidekiq (~> 2.2)
builder (3.0.0)
capistrano (2.12.0)
highline
@@ -59,6 +62,9 @@ GEM
capybara-webkit (0.12.1)
capybara (>= 1.0.0, < 1.2)
json
+ celluloid (0.12.3)
+ facter (>= 1.6.12)
+ timers (>= 1.0.0)
childprocess (0.3.5)
ffi (~> 1.0, >= 1.0.6)
coffee-rails (3.2.2)
@@ -68,6 +74,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.3.3)
+ connection_pool (0.9.2)
daemons (1.1.9)
database_cleaner (0.8.0)
dynamic_form (1.1.4)
@@ -76,38 +83,27 @@ GEM
excon (0.16.7)
execjs (1.4.0)
multi_json (~> 1.0)
+ facter (1.6.14)
factory_girl (2.3.2)
activesupport
factory_girl_rails (1.4.0)
factory_girl (~> 2.3.0)
railties (>= 3.0.0)
fakeweb (1.3.0)
- fattr (2.2.1)
ffi (1.1.5)
haml (3.1.6)
hashie (1.0.0)
- heroku (2.33.0)
- heroku-api (~> 0.3.5)
- launchy (>= 0.3.2)
- netrc (~> 0.7.7)
- rest-client (~> 1.6.1)
- rubyzip
heroku-api (0.3.6)
excon (~> 0.16.7)
highline (1.6.13)
hike (1.2.1)
- hirefire (0.1.4)
- heroku (>= 1.4)
- rush (~> 0.6.7)
hpricot (0.8.6)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.7.4)
- launchy (2.1.2)
- addressable (~> 2.3)
libwebsocket (0.1.5)
addressable
mail (2.4.4)
@@ -127,7 +123,6 @@ GEM
net-ssh (2.5.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
- netrc (0.7.7)
newrelic_rpm (3.5.0.1)
nokogiri (1.5.5)
oauth (0.4.6)
@@ -160,25 +155,12 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
- redis (3.0.1)
+ redis (3.0.2)
redis-namespace (1.2.1)
redis (~> 3.0.0)
- resque (1.22.0)
- multi_json (~> 1.0)
- redis-namespace (~> 1.0)
- sinatra (>= 0.9.2)
- vegas (~> 0.1.2)
- resque-scheduler (2.0.0)
- redis (>= 2.0.1)
- resque (>= 1.20.0)
- rufus-scheduler
rest-client (1.6.7)
mime-types (>= 1.16)
rubyzip (0.9.9)
- rufus-scheduler (2.0.17)
- tzinfo (>= 0.3.23)
- rush (0.6.8)
- session
rvm-capistrano (1.2.5)
capistrano (>= 2.0.0)
sass (3.1.20)
@@ -191,28 +173,37 @@ GEM
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
- session (3.1.0)
- fattr
shoulda (3.1.1)
shoulda-context (~> 1.0)
shoulda-matchers (~> 1.2)
shoulda-context (1.0.0)
shoulda-matchers (1.2.0)
activesupport (>= 3.0.0)
+ sidekiq (2.5.2)
+ celluloid (~> 0.12.0)
+ connection_pool (~> 0.9.2)
+ multi_json (~> 1)
+ redis (~> 3)
+ redis-namespace
sinatra (1.3.3)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
+ slim (1.3.3)
+ temple (~> 0.5.5)
+ tilt (~> 1.3.3)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
+ temple (0.5.5)
thin (1.5.0)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.15.4)
tilt (1.3.3)
+ timers (1.0.1)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
@@ -222,8 +213,6 @@ GEM
uglifier (1.2.7)
execjs (>= 0.3.0)
multi_json (~> 1.3)
- vegas (0.1.11)
- rack (>= 1.0.0)
will_paginate (3.0.3)
xpath (0.1.4)
nokogiri (~> 1.3)
@@ -232,6 +221,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ autoscaler
capistrano
capybara-webkit
coffee-rails (~> 3.2.1)
@@ -242,7 +232,6 @@ DEPENDENCIES
goodreads!
haml
hashie
- hirefire
hpricot
jquery-rails
json
@@ -252,11 +241,12 @@ DEPENDENCIES
oauth
pg
rails (= 3.2.8)
- resque (~> 1.22.0)
- resque-scheduler
rvm-capistrano
sass-rails (~> 3.2.3)
shoulda
+ sidekiq
+ sinatra
+ slim
thin
turn
uglifier (>= 1.0.3)
View
@@ -1,2 +1 @@
web: bundle exec rails server thin -p $PORT -e $RACK_ENV
-resquework: env QUEUE=* TERM_CHILD=1 bundle exec rake resque:work
@@ -11,7 +11,7 @@ def login
def oauth_callback
@user = get_authorized_user
@user.update_shelves
- Resque.enqueue(UpdateUser, @user.id)
+ UpdateUser.perform_async @user.id
session[:user_id] = @user.id
redirect_to :controller => :books, :action => :index
@@ -1,10 +1,9 @@
class QueueAllUsers
- @queue = :lookup
- def self.perform
+ def perform
User.find_each do |user|
puts "enqueuing #{user.id} - goodreads id #{user.goodreads_id}"
- Resque.enqueue(UpdateUser, user.id)
+ UpdateUser.perform_asyn user.id
end
end
end
@@ -1,7 +1,7 @@
class UpdateUser
- @queue = :lookup
+ include Sidekiq::Worker
- def self.perform(user_id)
+ def perform(user_id)
User.find(user_id).update!
end
end
View
@@ -1,14 +1,14 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
-require 'resque/server'
+require 'sidekiq/web'
-AUTH_PASSWORD = ENV['RESQUE_PASSWORD']
+AUTH_PASSWORD = ENV['SIDEKIQ_PASSWORD']
if AUTH_PASSWORD
- Resque::Server.use Rack::Auth::Basic do |username, password|
+ Sidekiq::Web.use Rack::Auth::Basic do |username, password|
password == AUTH_PASSWORD
end
end
run Rack::URLMap.new \
- "/" => Minuteman::Application,
- "/resque" => Resque::Server.new
+ "/" => Minuteman::Application,
+ "/sidekiq" => Sidekiq::Web
View
@@ -1,92 +0,0 @@
-#---
-# Excerpted from "Agile Web Development with Rails",
-# published by The Pragmatic Bookshelf.
-# Copyrights apply to this code. It may not be used to create training material,
-# courses, books, articles, and the like. Contact us if you are in doubt.
-# We make no guarantees that this code is fit for any purpose.
-# Visit http://www.pragmaticprogrammer.com/titles/rails4 for more book information.
-#---
-# be sure to change these
-set :user, 'tmayfield'
-set :domain, 'zen-hacking.com'
-set :application, 'literate-minuteman'
-
-# adjust if you are using RVM, remove if you are not
-require "rvm/capistrano"
-set :rvm_ruby_string, '1.9.3'
-
-# file paths
-set :repository, "git@github.com:thegreatape/#{application}.git"
-set :deploy_to, "/var/www/#{application}"
-
-# distribute your applications across servers (the instructions below put them
-# all on the same server, defined above as 'domain', adjust as necessary)
-role :app, domain
-role :web, domain
-role :db, domain, :primary => true
-
-# you might need to set this if you aren't seeing password prompts
-# default_run_options[:pty] = true
-
-# As Capistrano executes in a non-interactive mode and therefore doesn't cause
-# any of your shell profile scripts to be run, the following might be needed
-# if (for example) you have locally installed gems or applications. Note:
-# this needs to contain the full values for the variables set, not simply
-# the deltas.
-# default_environment['PATH']='<your paths>:/usr/local/bin:/usr/bin:/bin'
-# default_environment['GEM_PATH']='<your paths>:/usr/lib/ruby/gems/1.8'
-
-# miscellaneous options
-set :deploy_via, :remote_cache
-set :scm, 'git'
-set :branch, 'master'
-set :scm_verbose, true
-set :use_sudo, false
-set :rails_env, :production
-set :normalize_asset_timestamps, false
-
-namespace :deploy do
- desc "cause Passenger to initiate a restart"
- task :restart do
- run "touch #{current_path}/tmp/restart.txt"
- end
-
- desc "reload the database with seed data"
- task :seed do
- run "cd #{current_path}; rake db:seed RAILS_ENV=#{rails_env}"
- end
-end
-
-after "deploy:update_code", :update_config
-desc "copy prod db config and goodreads keys to deployment"
-task :update_config, :roles => :app do
- run "cd #{release_path} && cp /var/www/literate-minuteman-database.yml #{release_path}/config/database.yml"
- run "cd #{release_path} && cp /var/www/goodreads.rb #{release_path}/config/initializers/goodreads.rb"
-end
-
-after "deploy:update_code", :bundle_install
-desc "install the necessary prerequisites"
-task :bundle_install, :roles => :app do
- run "cd #{release_path} && bundle install --without=test"
-end
-
-after "bundle_install", :precompile_assets
-desc "precompile assets"
-task :precompile_assets, :roles => :app do
- run "cd #{release_path} && bundle exec rake assets:precompile"
-end
-
-after "precompile_assets", :db_migrate
-desc "run migrations"
-task :db_migrate, :roles => :app do
- run "cd #{release_path} && RAILS_ENV=production bundle exec rake db:migrate"
-end
-
-after "deploy:restart", :restart_resque
-desc "restart resque"
-task :restart_resque, :roles => :app do
- run "sudo stop resque-worker"
- run "sudo start resque-worker"
- run "sudo stop resque-scheduler"
- run "sudo start resque-scheduler"
-end
@@ -58,5 +58,4 @@
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
- Resque.redis = ENV['REDISTOGO_URL']
end
@@ -1,3 +0,0 @@
-HireFire.configure do |config|
- config.max_workers = 1
-end
View
@@ -1,16 +0,0 @@
-require 'resque/tasks'
-require 'resque_scheduler/tasks'
-
-
-namespace :resque do
- task :setup => :environment do
- ENV['QUEUE'] = '*'
- require 'resque'
- require 'resque_scheduler'
- require 'resque/scheduler'
- Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
- Resque.schedule = YAML.load_file("#{Rails.root}/config/resque-schedule.yml")
- end
-end
-
-

0 comments on commit 2b536f8

Please sign in to comment.