-
Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathworkers.rake
38 lines (36 loc) · 952 Bytes
/
workers.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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