Skip to content

Commit

Permalink
Add capistrano integration [#52]
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Feb 27, 2012
1 parent bf377d4 commit 9fb20f6
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
29 changes: 29 additions & 0 deletions lib/sidekiq/capistrano.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions myapp/Capfile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions myapp/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ gem 'rails', '3.2.1'
gem 'sqlite3'
gem 'sidekiq', :path => '..'
gem 'resque'
gem 'capistrano'
15 changes: 15 additions & 0 deletions myapp/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -111,6 +125,7 @@ PLATFORMS
ruby

DEPENDENCIES
capistrano
rails (= 3.2.1)
resque
sidekiq!
Expand Down
15 changes: 15 additions & 0 deletions myapp/config/deploy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'bundler/capistrano'
require 'sidekiq/capistrano'

set :scm, :git
set :repository, '[email protected]: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.