Sha256: 77383d23fc0196104f993832f40e1816e230ee6f22af5a0e1b8fa890e4ee0cbd

Contents?: true

Size: 1.45 KB

Versions: 10

Compression:

Stored size: 1.45 KB

Contents

# Capistrano plugin hook to set default values
namespace :load do
  task :defaults do
    set :sidekiq_systemd_role, fetch(:sidekiq_systemd_role, :app)
    set :sidekiq_systemd_use_hooks, fetch(:sidekiq_systemd_use_hooks, false)
  end
end

# Integrate sidekiq hooks into Capistrano
namespace :deploy do
  before :starting, :add_sidekiq_systemd_hooks do
    invoke 'sidekiq_systemd:add_hooks' if fetch(:sidekiq_systemd_use_hooks)
  end
end

namespace :sidekiq_systemd do
  # NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
  task :add_hooks do
    after 'deploy:failed', 'sidekiq_systemd:restart'
    after 'deploy:published', 'sidekiq_systemd:start'
    after 'deploy:starting', 'sidekiq_systemd:quiet'
    after 'deploy:updated', 'sidekiq_systemd:stop'
  end

  desc 'Stop workers from picking up new jobs'
  task :quiet do
    on roles fetch(:sidekiq_systemd_role) do
      sudo :systemctl, 'reload', 'sidekiq-*', raise_on_non_zero_exit: false
    end
  end

  desc 'Stop running workers gracefully'
  task :stop do
    on roles fetch(:sidekiq_systemd_role) do
      sudo :systemctl, 'stop', 'sidekiq-*'
    end
  end

  desc 'Start workers'
  task :start do
    on roles fetch(:sidekiq_systemd_role) do
      sudo :systemctl, 'start', 'sidekiq-*', '--all'
    end
  end

  desc 'Restart workers'
  task :restart do
    on roles fetch(:sidekiq_systemd_role) do
      sudo :systemctl, 'restart', 'sidekiq-*', raise_on_non_zero_exit: false
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dlss-capistrano-4.1.0 lib/dlss/capistrano/tasks/sidekiq_systemd.rake
dlss-capistrano-4.0.0 lib/dlss/capistrano/tasks/sidekiq_systemd.rake
dlss-capistrano-3.11.1 lib/dlss/capistrano/tasks/sidekiq_systemd.rake
dlss-capistrano-3.11.0 lib/dlss/capistrano/tasks/sidekiq_systemd.rake
dlss-capistrano-3.10.1 lib/dlss/capistrano/tasks/sidekiq_systemd.rake
dlss-capistrano-3.10.0 lib/dlss/capistrano/tasks/sidekiq_systemd.rake
dlss-capistrano-3.9.0 lib/dlss/capistrano/tasks/sidekiq_systemd.rake
dlss-capistrano-3.8.0 lib/dlss/capistrano/tasks/sidekiq_systemd.rake
dlss-capistrano-3.7.0 lib/dlss/capistrano/tasks/sidekiq_systemd.rake
dlss-capistrano-3.6.0 lib/dlss/capistrano/tasks/sidekiq_systemd.rake