Sha256: 11263b48e021581e2ba8332b276ab2200b88d42a3036c83369704f63c83a909e

Contents?: true

Size: 1.21 KB

Versions: 17

Compression:

Stored size: 1.21 KB

Contents

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

# Integrate sneakers hooks into Capistrano
namespace :deploy do
  before :starting, :add_sneakers_systemd_hooks do
    invoke 'sneakers_systemd:add_hooks' if fetch(:sneakers_systemd_use_hooks)
  end
end

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

  desc 'Stop running workers gracefully'
  task :stop do
    on roles(fetch(:sneakers_systemd_role)) do
      sudo :systemctl, 'stop', 'sneakers'
    end
  end

  desc 'Start workers'
  task :start do
    on roles(fetch(:sneakers_systemd_role)) do
      sudo :systemctl, 'start', 'sneakers'
    end
  end

  desc 'Restart workers'
  task :restart do
    on roles(fetch(:sneakers_systemd_role)) do
      sudo :systemctl, 'restart', 'sneakers', raise_on_non_zero_exit: false
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
dlss-capistrano-5.3.0 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-5.2.0 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-5.1.1 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-5.1.0 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-5.0.4 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-5.0.3 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-5.0.2 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-5.0.1 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-5.0.0 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-4.4.1 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-4.4.0 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-4.3.1 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-4.3.0 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-4.2.1 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-4.2.0 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-4.1.2 lib/dlss/capistrano/tasks/sneakers_systemd.rake
dlss-capistrano-4.1.1 lib/dlss/capistrano/tasks/sneakers_systemd.rake