Sha256: 884cee54538dd179c0d7239278de60b2bc963797641f68f89b503566b5b2ad59

Contents?: true

Size: 1016 Bytes

Versions: 4

Compression:

Stored size: 1016 Bytes

Contents

git_plugin = self

namespace :puma do
  namespace :workers do
    desc 'Add a worker'
    task :count do
      on roles(fetch(:puma_role)) do |role|
        git_plugin.puma_switch_user(role) do
          #TODO
          # cleanup
          # add host name/ip
          workers_count = capture("ps ax | grep -c 'puma: cluster worker [0-9]: `cat  #{fetch(:puma_pid)}`'").to_i - 1
          log "Workers count : #{workers_count}"
        end
      end
    end

    # TODO
    # Add/remove workers to specific host/s
    # Define  # of workers to add/remove
    # Refactor
    desc 'Worker++'
    task :more do
      on roles(fetch(:puma_role)) do |role|
        git_plugin.puma_switch_user(role) do
          execute(:kill, "-TTIN `cat  #{fetch(:puma_pid)}`")
        end
      end
    end

    desc 'Worker--'
    task :less do
      on roles(fetch(:puma_role)) do |role|
        git_plugin.puma_switch_user(role) do
          execute(:kill, "-TTOU `cat  #{fetch(:puma_pid)}`")
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
capistrano3-puma-3.0.3 lib/capistrano/tasks/workers.rake
capistrano3-puma-3.0.2 lib/capistrano/tasks/workers.rake
capistrano3-puma-3.0.1 lib/capistrano/tasks/workers.rake
capistrano3-puma-3.0.0 lib/capistrano/tasks/workers.rake