Sha256: d25b6d15f7b8ddf85f579fc1afa9b03bb2e8d2f300f6c35cff8e3cd3f6b22e74

Contents?: true

Size: 948 Bytes

Versions: 2

Compression:

Stored size: 948 Bytes

Contents

namespace :puma do
  namespace :workers do
    desc 'Add a worker'
    task :count do
      on roles (fetch(:puma_role)) do |role|
        puma_switch_user(role) do
        #TODO
        # cleanup
        # add host name/ip
        workers_count = capture("ps ax | grep -c 'puma: cluster worker: `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|
        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|
        puma_switch_user(role) do
          execute("kill -TTOU `cat  #{fetch(:puma_pid)}`")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano3-puma-1.2.1 lib/capistrano/tasks/workers.rake
capistrano3-puma-1.2.0 lib/capistrano/tasks/workers.rake