Sha256: be7591f7fbde7fbe0d18dfd360f96cc2080c000694226a2986cbbd6e76972219

Contents?: true

Size: 617 Bytes

Versions: 2

Compression:

Stored size: 617 Bytes

Contents

require 'capistrano/puma/utility'

include Capistrano::Puma::Utility

namespace :puma do
  namespace :workers do
    desc 'Number of workers'
    task :count do
      on roles puma_roles do |host|
        check_puma_pid

        pid = capture("cat #{fetch(:puma_pid)}").strip
        workers_count = capture("ps ax | grep -c 'puma: cluster worker [0-9]\\+: #{pid}'").to_i

        log "Workers on #{host.hostname}: #{workers_count}"
      end
    end

    desc 'Add a worker'
    task :add do
      puma_signal(:TTIN)
    end

    desc 'Remove a worker'
    task :remove do
      puma_signal(:TTOU)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-puma-sic-0.2.0 lib/capistrano/tasks/workers.cap
capistrano-puma-sic-0.1.0 lib/capistrano/tasks/workers.cap