Permalink
Browse files

Add capistrano integration [#52]

  • Loading branch information...
1 parent bf377d4 commit 9fb20f6249a9442aa604065c3e90e44cf043c062 @mperham mperham committed Feb 27, 2012
Showing with 67 additions and 0 deletions.
  1. +2 −0 Changes.md
  2. +29 −0 lib/sidekiq/capistrano.rb
  3. +5 −0 myapp/Capfile
  4. +1 −0 myapp/Gemfile
  5. +15 −0 myapp/Gemfile.lock
  6. +15 −0 myapp/config/deploy.rb
View
@@ -1,6 +1,8 @@
HEAD
-----------
+- Add capistrano support, just require 'sidekiq/capistrano' in config/deploy.rb.
+- Workers now log upon start and finish (mperham)
- Messages for terminated workers are now automatically requeued (mperham)
- Add support for Exceptional error reporting (bensie)
View
@@ -0,0 +1,29 @@
+Capistrano::Configuration.instance.load do
+ after "deploy", "sidekiq:restart"
+
+ namespace :sidekiq do
+
+ desc "Force stop sidekiq"
+ task :kill do
+ run "cd #{current_path} && kill `cat tmp/pids/sidekiq.pid` && sleep 5 && kill -9 `cat tmp/pids/sidekiq.pid`"
+ end
+
+ desc "Stop sidekiq"
+ task :stop do
+ run "cd #{current_path} && kill `cat tmp/pids/sidekiq.pid`"
+ end
+
+ desc "Start sidekiq"
+ task :start do
+ rails_env = fetch(:rails_env, "production")
+ run "cd #{current_path} && bundle exec sidekiq -e #{rails_env} -C config/sidekiq.yml -P tmp/pids/sidekiq.pid >> log/sidekiq.log &"
+ end
+
+ desc "Restart sidekiq"
+ task :restart do
+ stop
+ start
+ end
+
+ end
+end
View
@@ -0,0 +1,5 @@
+load 'deploy'
+# Uncomment if you are using Rails' asset pipeline
+ # load 'deploy/assets'
+Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
+load 'config/deploy' # remove this line to skip loading any of the default tasks
View
@@ -4,3 +4,4 @@ gem 'rails', '3.2.1'
gem 'sqlite3'
gem 'sidekiq', :path => '..'
gem 'resque'
+gem 'capistrano'
View
@@ -40,9 +40,16 @@ GEM
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
+ capistrano (2.11.2)
+ highline
+ net-scp (>= 1.0.0)
+ net-sftp (>= 2.0.0)
+ net-ssh (>= 2.0.14)
+ net-ssh-gateway (>= 1.1.0)
celluloid (0.9.0)
connection_pool (0.1.0)
erubis (2.7.0)
+ highline (1.6.11)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.2)
@@ -53,6 +60,13 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.1.0)
+ net-scp (1.0.4)
+ net-ssh (>= 1.99.1)
+ net-sftp (2.0.5)
+ net-ssh (>= 2.0.9)
+ net-ssh (2.3.0)
+ net-ssh-gateway (1.1.0)
+ net-ssh (>= 1.99.1)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.1)
@@ -111,6 +125,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ capistrano
rails (= 3.2.1)
resque
sidekiq!
View
@@ -0,0 +1,15 @@
+require 'bundler/capistrano'
+require 'sidekiq/capistrano'
+
+set :scm, :git
+set :repository, 'git@github.com:mperham/sidekiq'
+ssh_options[:forward_agent] = true
+
+default_run_options[:pty] = true # needed to run sudo
+set :user, 'mperham'
+set :application, "myapp"
+set :deploy_via, :remote_cache
+
+role :web, "localhost"
+role :app, "localhost"
+role :db, "localhost", :primary => true

0 comments on commit 9fb20f6

Please sign in to comment.