Sha256: 4b4acb2182d5f6620a8b8e7a55d5bbee97b9bb8897c5485ab3e8843ab71eae01

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

Capistrano::Configuration.instance.load do
  before "deploy", "sidekiq:quiet"
  after "deploy", "sidekiq:restart"

  _cset(:sidekiq_timeout) { 10 }
  _cset(:sidekiq_role) { :app }

  namespace :sidekiq do

    desc "Quiet sidekiq (stop accepting new work)"
    task :quiet, :roles => lambda { fetch(:sidekiq_role) } do
      run "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then bundle exec sidekiqctl quiet #{current_path}/tmp/pids/sidekiq.pid ; fi"
    end

    desc "Stop sidekiq"
    task :stop, :roles => lambda { fetch(:sidekiq_role) } do
      run "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then bundle exec sidekiqctl stop #{current_path}/tmp/pids/sidekiq.pid #{fetch :sidekiq_timeout} ; fi"
    end

    desc "Start sidekiq"
    task :start, :roles => lambda { fetch(:sidekiq_role) } do
      rails_env = fetch(:rails_env, "production")
      run "cd #{current_path} ; nohup bundle exec sidekiq -e #{rails_env} -C #{current_path}/config/sidekiq.yml -P #{current_path}/tmp/pids/sidekiq.pid >> #{current_path}/log/sidekiq.log 2>&1 &"
    end

    desc "Restart sidekiq"
    task :restart, :roles => lambda { fetch(:sidekiq_role) } do
      stop
      start
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sidekiq-1.1.0 lib/sidekiq/capistrano.rb
sidekiq-1.0.0 lib/sidekiq/capistrano.rb
sidekiq-0.11.2 lib/sidekiq/capistrano.rb