Sha256: c3c987fdf3ef97d42527b6973388e74dcdf3cdd1a2d190d77fc7ed362f0eebf6

Contents?: true

Size: 1.19 KB

Versions: 11

Compression:

Stored size: 1.19 KB

Contents

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

# Integrate racecar hooks into Capistrano
namespace :deploy do
  before :starting, :add_racecar_systemd_hooks do
    invoke 'racecar_systemd:add_hooks' if fetch(:racecar_systemd_use_hooks)
  end
end

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

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

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dlss-capistrano-5.3.0 lib/dlss/capistrano/tasks/racecar_systemd.rake
dlss-capistrano-5.2.0 lib/dlss/capistrano/tasks/racecar_systemd.rake
dlss-capistrano-5.1.1 lib/dlss/capistrano/tasks/racecar_systemd.rake
dlss-capistrano-5.1.0 lib/dlss/capistrano/tasks/racecar_systemd.rake
dlss-capistrano-5.0.4 lib/dlss/capistrano/tasks/racecar_systemd.rake
dlss-capistrano-5.0.3 lib/dlss/capistrano/tasks/racecar_systemd.rake
dlss-capistrano-5.0.2 lib/dlss/capistrano/tasks/racecar_systemd.rake
dlss-capistrano-5.0.1 lib/dlss/capistrano/tasks/racecar_systemd.rake
dlss-capistrano-5.0.0 lib/dlss/capistrano/tasks/racecar_systemd.rake
dlss-capistrano-4.4.1 lib/dlss/capistrano/tasks/racecar_systemd.rake
dlss-capistrano-4.4.0 lib/dlss/capistrano/tasks/racecar_systemd.rake