process_bot 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +0 -5
- data/Gemfile.lock +55 -52
- data/README.md +4 -1
- data/exe/process_bot +1 -2
- data/lib/process_bot/capistrano/custom.rake +31 -0
- data/lib/process_bot/capistrano/puma/common.rb +1 -1
- data/lib/process_bot/capistrano/sidekiq_helpers.rb +5 -1
- data/lib/process_bot/client_socket.rb +1 -1
- data/lib/process_bot/control_socket.rb +23 -11
- data/lib/process_bot/logger.rb +4 -0
- data/lib/process_bot/process/handlers/custom.rb +54 -0
- data/lib/process_bot/process/handlers/sidekiq.rb +13 -6
- data/lib/process_bot/process/runner.rb +67 -25
- data/lib/process_bot/process.rb +22 -3
- data/lib/process_bot/version.rb +1 -1
- data/process_bot.gemspec +5 -1
- metadata +61 -7
- data/sig/process_bot.rbs +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f2f79412eb217c8a18aa20f8f54e0009bbc646c51ad253a852889b80d4e2a04
|
4
|
+
data.tar.gz: ccb5234f5d4e43d00f1bb12256d01eac975c40e4ed7d8c393ff9c990022fd459
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9860f2583903182f3e8cb5ca55dc181fcc0fdd41c2a895f9d50899627b7bcc1279cdfc4089d4ad69f9ed97e36f311f3d4a00949581add9082589e4ab947ea709
|
7
|
+
data.tar.gz: 1a54dca286519b9f16786ba142fca462906218fd2ef1fdd0e50cfb75332502ccc4a295706348d1e415c965d253d6c4c8fb6a20758c179caf20696ae2a42677ec
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
process_bot (0.1.
|
4
|
+
process_bot (0.1.6)
|
5
5
|
knjrbfw (>= 0.0.116)
|
6
|
+
pry
|
7
|
+
rake
|
8
|
+
rspec
|
9
|
+
string-cases
|
6
10
|
|
7
11
|
GEM
|
8
12
|
remote: https://rubygems.org/
|
9
13
|
specs:
|
10
|
-
ast (2.4.
|
14
|
+
ast (2.4.3)
|
11
15
|
coderay (1.1.3)
|
12
16
|
datet (0.0.25)
|
13
|
-
diff-lcs (1.
|
17
|
+
diff-lcs (1.6.2)
|
14
18
|
http2 (0.0.36)
|
15
19
|
string-cases (~> 0)
|
16
|
-
json (2.
|
20
|
+
json (2.13.2)
|
17
21
|
knjrbfw (0.0.116)
|
18
22
|
datet
|
19
23
|
http2
|
@@ -21,63 +25,63 @@ GEM
|
|
21
25
|
ruby_process
|
22
26
|
tsafe
|
23
27
|
wref (>= 0.0.8)
|
24
|
-
language_server-protocol (3.17.0.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
language_server-protocol (3.17.0.5)
|
29
|
+
lint_roller (1.1.0)
|
30
|
+
method_source (1.1.0)
|
31
|
+
parallel (1.27.0)
|
32
|
+
parser (3.3.9.0)
|
28
33
|
ast (~> 2.4.1)
|
29
34
|
racc
|
30
35
|
php4r (0.0.4)
|
31
36
|
datet
|
32
37
|
http2
|
33
38
|
string-strtr
|
34
|
-
|
39
|
+
prism (1.4.0)
|
40
|
+
pry (0.15.2)
|
35
41
|
coderay (~> 1.1)
|
36
42
|
method_source (~> 1.0)
|
37
|
-
racc (1.
|
43
|
+
racc (1.8.1)
|
38
44
|
rainbow (3.1.1)
|
39
|
-
rake (13.
|
40
|
-
|
41
|
-
|
42
|
-
rspec (3.
|
43
|
-
rspec-core (~> 3.
|
44
|
-
rspec-expectations (~> 3.
|
45
|
-
rspec-mocks (~> 3.
|
46
|
-
rspec-core (3.
|
47
|
-
rspec-support (~> 3.
|
48
|
-
rspec-expectations (3.
|
45
|
+
rake (13.3.0)
|
46
|
+
ref (2.0.0)
|
47
|
+
regexp_parser (2.11.2)
|
48
|
+
rspec (3.13.1)
|
49
|
+
rspec-core (~> 3.13.0)
|
50
|
+
rspec-expectations (~> 3.13.0)
|
51
|
+
rspec-mocks (~> 3.13.0)
|
52
|
+
rspec-core (3.13.5)
|
53
|
+
rspec-support (~> 3.13.0)
|
54
|
+
rspec-expectations (3.13.5)
|
49
55
|
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
-
rspec-support (~> 3.
|
51
|
-
rspec-mocks (3.
|
56
|
+
rspec-support (~> 3.13.0)
|
57
|
+
rspec-mocks (3.13.5)
|
52
58
|
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
-
rspec-support (~> 3.
|
54
|
-
rspec-support (3.
|
55
|
-
rubocop (1.
|
59
|
+
rspec-support (~> 3.13.0)
|
60
|
+
rspec-support (3.13.5)
|
61
|
+
rubocop (1.80.0)
|
56
62
|
json (~> 2.3)
|
57
|
-
language_server-protocol (
|
63
|
+
language_server-protocol (~> 3.17.0.2)
|
64
|
+
lint_roller (~> 1.1.0)
|
58
65
|
parallel (~> 1.10)
|
59
|
-
parser (>= 3.
|
66
|
+
parser (>= 3.3.0.2)
|
60
67
|
rainbow (>= 2.2.2, < 4.0)
|
61
|
-
regexp_parser (>=
|
62
|
-
|
63
|
-
rubocop-ast (>= 1.30.0, < 2.0)
|
68
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
69
|
+
rubocop-ast (>= 1.46.0, < 2.0)
|
64
70
|
ruby-progressbar (~> 1.7)
|
65
|
-
unicode-display_width (>= 2.4.0, <
|
66
|
-
rubocop-ast (1.
|
67
|
-
parser (>= 3.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
rubocop (
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
rubocop (~> 1.
|
79
|
-
rubocop-capybara (~> 2.17)
|
80
|
-
rubocop-factory_bot (~> 2.22)
|
71
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
72
|
+
rubocop-ast (1.46.0)
|
73
|
+
parser (>= 3.3.7.2)
|
74
|
+
prism (~> 1.4)
|
75
|
+
rubocop-performance (1.25.0)
|
76
|
+
lint_roller (~> 1.1)
|
77
|
+
rubocop (>= 1.75.0, < 2.0)
|
78
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
79
|
+
rubocop-rake (0.7.1)
|
80
|
+
lint_roller (~> 1.1)
|
81
|
+
rubocop (>= 1.72.1)
|
82
|
+
rubocop-rspec (3.6.0)
|
83
|
+
lint_roller (~> 1.1)
|
84
|
+
rubocop (~> 1.72, >= 1.72.1)
|
81
85
|
ruby-progressbar (1.13.0)
|
82
86
|
ruby_process (0.0.13)
|
83
87
|
string-cases
|
@@ -86,8 +90,11 @@ GEM
|
|
86
90
|
string-cases (0.0.4)
|
87
91
|
string-strtr (0.0.3)
|
88
92
|
tsafe (0.0.12)
|
89
|
-
unicode-display_width (
|
90
|
-
|
93
|
+
unicode-display_width (3.1.5)
|
94
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
95
|
+
unicode-emoji (4.0.4)
|
96
|
+
wref (0.0.11)
|
97
|
+
ref
|
91
98
|
|
92
99
|
PLATFORMS
|
93
100
|
ruby
|
@@ -95,14 +102,10 @@ PLATFORMS
|
|
95
102
|
|
96
103
|
DEPENDENCIES
|
97
104
|
process_bot!
|
98
|
-
pry
|
99
|
-
rake
|
100
|
-
rspec
|
101
105
|
rubocop
|
102
106
|
rubocop-performance
|
103
107
|
rubocop-rake
|
104
108
|
rubocop-rspec
|
105
|
-
string-cases
|
106
109
|
|
107
110
|
BUNDLED WITH
|
108
111
|
2.3.8
|
data/README.md
CHANGED
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
Run your app through ProcessBot for automatic restart if crashing, but still support normal deployment through Capistrano.
|
4
4
|
|
5
|
-
|
5
|
+
Watch memory usage for Sidekiq and restart gracefully if it exceeds a given limit (to counter memory leaks).
|
6
|
+
|
7
|
+
When deploying can gracefully exit Sidekiq to let long running jobs finish on old version of code, and start new Sidekiq processes after finishing deploy (but still let the old ones finish gracefully so nothing gets interrupted).
|
8
|
+
This requires not to remove columns, rename columns or any other intrusive database changes.
|
6
9
|
|
7
10
|
## Installation
|
8
11
|
|
data/exe/process_bot
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
git_plugin = self
|
2
|
+
|
3
|
+
namespace :process_bot do
|
4
|
+
namespace :custom do
|
5
|
+
desc "Stops the custom command"
|
6
|
+
task :stop do
|
7
|
+
git_plugin.process_bot_command(
|
8
|
+
process_bot_data,
|
9
|
+
:stop,
|
10
|
+
"--handler" => "custom",
|
11
|
+
"--name" => ENV.fetch("PROCESS_BOT_CUSTOM_ID")
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Starts a custom command"
|
16
|
+
task :start do
|
17
|
+
git_plugin.process_bot_command(
|
18
|
+
process_bot_data,
|
19
|
+
:start,
|
20
|
+
"--handler" => "custom",
|
21
|
+
"--name" => ENV.fetch("PROCESS_BOT_CUSTOM_ID")
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Restart a custom command"
|
26
|
+
task :restart do
|
27
|
+
invoke! "process_bot:custom:stop"
|
28
|
+
invoke! "process_bot:custom:start"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -32,7 +32,7 @@ module ProcessBot::Capistrano::SidekiqHelpers # rubocop:disable Metrics/ModuleLe
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def process_bot_command(process_bot_data, command) # rubocop:disable Metrics/AbcSize
|
35
|
+
def process_bot_command(process_bot_data, command, args = {}) # rubocop:disable Metrics/AbcSize
|
36
36
|
raise "No port in process bot data? #{process_bot_data}" unless process_bot_data["port"]
|
37
37
|
|
38
38
|
mode = "exec"
|
@@ -55,6 +55,10 @@ module ProcessBot::Capistrano::SidekiqHelpers # rubocop:disable Metrics/ModuleLe
|
|
55
55
|
"--command #{command} " \
|
56
56
|
"--port #{process_bot_data.fetch("port")}"
|
57
57
|
|
58
|
+
args.each do |key, value|
|
59
|
+
backend_command << "#{key} #{value}"
|
60
|
+
end
|
61
|
+
|
58
62
|
if command == :graceful && !fetch(:process_bot_wait_for_gracefully_stopped).nil?
|
59
63
|
backend_command << " --wait-for-gracefully-stopped #{fetch(:process_bot_wait_for_gracefully_stopped)}"
|
60
64
|
end
|
@@ -1,32 +1,44 @@
|
|
1
1
|
require "socket"
|
2
2
|
|
3
3
|
class ProcessBot::ControlSocket
|
4
|
-
attr_reader :options, :process, :server
|
4
|
+
attr_reader :options, :port, :process, :server
|
5
5
|
|
6
6
|
def initialize(options:, process:)
|
7
7
|
@options = options
|
8
8
|
@process = process
|
9
|
+
@port = options.fetch(:port).to_i
|
9
10
|
end
|
10
11
|
|
11
12
|
def logger
|
12
13
|
@logger ||= ProcessBot::Logger.new(options: options)
|
13
14
|
end
|
14
15
|
|
15
|
-
def port
|
16
|
-
options.fetch(:port).to_i
|
17
|
-
end
|
18
|
-
|
19
16
|
def start
|
20
|
-
|
17
|
+
start_tcp_server
|
21
18
|
run_client_loop
|
22
|
-
|
23
19
|
logger.logs "TCPServer started"
|
20
|
+
options.events.call(:on_socket_opened, port: @port)
|
21
|
+
end
|
22
|
+
|
23
|
+
def start_tcp_server
|
24
|
+
tries ||= 0
|
25
|
+
tries += 1
|
26
|
+
@server = actually_start_tcp_server("localhost", @port)
|
27
|
+
rescue Errno::EADDRINUSE, Errno::EADDRNOTAVAIL => e
|
28
|
+
if tries <= 100
|
29
|
+
@port += 1
|
30
|
+
retry
|
31
|
+
else
|
32
|
+
raise e
|
33
|
+
end
|
34
|
+
end
|
24
35
|
|
25
|
-
|
36
|
+
def actually_start_tcp_server(host, port)
|
37
|
+
TCPServer.new(host, port)
|
26
38
|
end
|
27
39
|
|
28
40
|
def stop
|
29
|
-
server
|
41
|
+
server&.close
|
30
42
|
end
|
31
43
|
|
32
44
|
def run_client_loop
|
@@ -60,8 +72,8 @@ class ProcessBot::ControlSocket
|
|
60
72
|
process.__send__(command_type, **command_options)
|
61
73
|
client.puts(JSON.generate(type: "success"))
|
62
74
|
rescue => e # rubocop:disable Style/RescueStandardError
|
63
|
-
logger.
|
64
|
-
logger.
|
75
|
+
logger.error e.message
|
76
|
+
logger.error e.backtrace
|
65
77
|
|
66
78
|
client.puts(JSON.generate(type: "error", message: e.message, backtrace: e.backtrace))
|
67
79
|
|
data/lib/process_bot/logger.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
class ProcessBot::Process::Handlers::Custom
|
2
|
+
attr_reader :options, :process
|
3
|
+
|
4
|
+
def initialize(process)
|
5
|
+
@process = process
|
6
|
+
@options = process.options
|
7
|
+
end
|
8
|
+
|
9
|
+
def current_pid
|
10
|
+
process.current_pid
|
11
|
+
end
|
12
|
+
|
13
|
+
def daemonize
|
14
|
+
logger.logs "Daemonize!"
|
15
|
+
|
16
|
+
pid = Process.fork do
|
17
|
+
Process.daemon
|
18
|
+
yield
|
19
|
+
end
|
20
|
+
|
21
|
+
Process.detach(pid) if pid
|
22
|
+
end
|
23
|
+
|
24
|
+
def false_value?(value)
|
25
|
+
!value || value == "false"
|
26
|
+
end
|
27
|
+
|
28
|
+
def fetch(*args, **opts)
|
29
|
+
options.fetch(*args, **opts)
|
30
|
+
end
|
31
|
+
|
32
|
+
def logger
|
33
|
+
@logger ||= ProcessBot::Logger.new(options: options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_option(key, value)
|
37
|
+
raise "Unknown option for Sidekiq handler: #{key}" unless options.key?(key)
|
38
|
+
|
39
|
+
set(key, value)
|
40
|
+
end
|
41
|
+
|
42
|
+
def set(*args, **opts)
|
43
|
+
options.set(*args, **opts)
|
44
|
+
end
|
45
|
+
|
46
|
+
def start_command
|
47
|
+
"bash -c 'cd #{options.fetch(:release_path)} && #{options.options.fetch(:custom_command)}'"
|
48
|
+
end
|
49
|
+
|
50
|
+
def stop(**_args)
|
51
|
+
puts "Stop related processes"
|
52
|
+
process.runner.stop_related_processes
|
53
|
+
end
|
54
|
+
end
|
@@ -92,20 +92,27 @@ class ProcessBot::Process::Handlers::Sidekiq
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def stop(**_args)
|
95
|
-
|
95
|
+
if current_pid
|
96
|
+
Process.kill("TERM", current_pid)
|
97
|
+
else
|
98
|
+
related_sidekiq_processes = process.runner.related_sidekiq_processes
|
96
99
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
+
if related_sidekiq_processes.empty?
|
101
|
+
logger.error "#{handler_name} didn't have any processes running"
|
102
|
+
else
|
103
|
+
related_sidekiq_processes.each do |related_sidekiq_process|
|
104
|
+
Process.kill("TERM", related_sidekiq_process.pid)
|
105
|
+
end
|
106
|
+
end
|
100
107
|
end
|
101
|
-
|
102
|
-
Process.kill("TERM", current_pid)
|
103
108
|
end
|
104
109
|
|
105
110
|
def wait_for_no_jobs # rubocop:disable Metrics/AbcSize
|
106
111
|
loop do
|
107
112
|
found_process = false
|
108
113
|
|
114
|
+
raise "No current PID for Sidekiq" unless current_pid
|
115
|
+
|
109
116
|
Knj::Unix_proc.list("grep" => current_pid) do |process|
|
110
117
|
process_command = process.data.fetch("cmd")
|
111
118
|
process_pid = process.data.fetch("pid").to_i
|
@@ -1,14 +1,15 @@
|
|
1
1
|
require "knjrbfw"
|
2
2
|
|
3
3
|
class ProcessBot::Process::Runner
|
4
|
-
attr_reader :command, :exit_status, :logger, :monitor, :options, :pid, :stop_time, :subprocess_pid
|
4
|
+
attr_reader :command, :exit_status, :handler_instance, :handler_name, :logger, :monitor, :options, :pid, :stop_time, :subprocess_pid
|
5
5
|
|
6
|
-
def initialize(command:, logger:, options:)
|
6
|
+
def initialize(command:, handler_instance:, handler_name:, logger:, options:)
|
7
7
|
@command = command
|
8
|
+
@handler_instance = handler_instance
|
9
|
+
@handler_name = handler_name
|
8
10
|
@logger = logger
|
9
11
|
@monitor = Monitor.new
|
10
12
|
@options = options
|
11
|
-
@output = []
|
12
13
|
end
|
13
14
|
|
14
15
|
def output(output:, type:)
|
@@ -52,11 +53,13 @@ class ProcessBot::Process::Runner
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
find_sidekiq_pid
|
56
|
+
find_sidekiq_pid if handler_name == "sidekiq"
|
56
57
|
|
57
58
|
stdout_reader_thread.join
|
58
59
|
stderr_reader_thread.join
|
59
60
|
|
61
|
+
logger.logs "Process stopped"
|
62
|
+
|
60
63
|
@stop_time = Time.new
|
61
64
|
end
|
62
65
|
end
|
@@ -69,32 +72,71 @@ class ProcessBot::Process::Runner
|
|
69
72
|
options.fetch(:application)
|
70
73
|
end
|
71
74
|
|
72
|
-
def
|
73
|
-
|
74
|
-
while running? && !pid
|
75
|
-
Knj::Unix_proc.list("grep" => "sidekiq") do |process|
|
76
|
-
cmd = process.data.fetch("cmd")
|
75
|
+
def related_processes
|
76
|
+
related_processes = []
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
Knj::Unix_proc.list do |process|
|
79
|
+
begin
|
80
|
+
process_pgid = Process.getpgid(process.pid)
|
81
|
+
rescue Errno::ESRCH
|
82
|
+
# Process no longer running
|
83
|
+
end
|
80
84
|
|
81
|
-
|
82
|
-
|
83
|
-
rescue Errno::ESRCH
|
84
|
-
# Process no longer running
|
85
|
-
end
|
85
|
+
related_processes << process if subprocess_pgid == process_pgid
|
86
|
+
end
|
86
87
|
|
87
|
-
|
88
|
-
|
88
|
+
related_processes
|
89
|
+
end
|
89
90
|
|
90
|
-
|
91
|
-
|
91
|
+
def related_sidekiq_processes
|
92
|
+
related_sidekiq_processes = []
|
92
93
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
Knj::Unix_proc.list("grep" => "sidekiq") do |process|
|
95
|
+
cmd = process.data.fetch("cmd")
|
96
|
+
|
97
|
+
if /sidekiq ([0-9]+\.[0-9]+\.[0-9]+) (#{options.possible_process_titles_joined_regex})/.match?(cmd)
|
98
|
+
sidekiq_pid = process.data.fetch("pid").to_i
|
99
|
+
|
100
|
+
begin
|
101
|
+
sidekiq_pgid = Process.getpgid(sidekiq_pid)
|
102
|
+
rescue Errno::ESRCH
|
103
|
+
# Process no longer running
|
104
|
+
end
|
105
|
+
|
106
|
+
related_sidekiq_processes << process if subprocess_pgid == sidekiq_pgid
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
related_sidekiq_processes
|
111
|
+
end
|
112
|
+
|
113
|
+
def stop_related_processes
|
114
|
+
loop do
|
115
|
+
processes = related_processes
|
116
|
+
|
117
|
+
if processes.length <= 0
|
118
|
+
logger.logs "No related processes could be found"
|
119
|
+
break
|
120
|
+
else
|
121
|
+
processes.each do |process|
|
122
|
+
logger.logs "Terminating PID #{process.pid}: #{process.data.fetch("cmd")}"
|
123
|
+
Process.kill("TERM", process.pid)
|
124
|
+
end
|
125
|
+
|
126
|
+
sleep 0.5
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def find_sidekiq_pid
|
132
|
+
Thread.new do
|
133
|
+
while running? && !pid
|
134
|
+
related_sidekiq_processes.each do |related_sidekiq_process| # rubocop:disable Lint/UnreachableLoop
|
135
|
+
puts "FOUND PID: #{related_sidekiq_process.pid}"
|
136
|
+
@pid = related_sidekiq_process.pid
|
137
|
+
options.events.call(:on_process_started, pid: related_sidekiq_process.pid)
|
138
|
+
|
139
|
+
break
|
98
140
|
end
|
99
141
|
|
100
142
|
unless pid
|
data/lib/process_bot/process.rb
CHANGED
@@ -29,7 +29,11 @@ class ProcessBot::Process
|
|
29
29
|
if command == "start"
|
30
30
|
start
|
31
31
|
elsif command == "graceful" || command == "stop"
|
32
|
-
|
32
|
+
begin
|
33
|
+
client.send_command(command: command, options: options.options)
|
34
|
+
rescue Errno::ECONNREFUSED => e
|
35
|
+
raise e unless options[:ignore_no_process_bot]
|
36
|
+
end
|
33
37
|
else
|
34
38
|
raise "Unknown command: #{command}"
|
35
39
|
end
|
@@ -68,6 +72,10 @@ class ProcessBot::Process
|
|
68
72
|
update_process_title
|
69
73
|
end
|
70
74
|
|
75
|
+
def set_stopped
|
76
|
+
@stopped = true
|
77
|
+
end
|
78
|
+
|
71
79
|
def start_control_socket
|
72
80
|
@control_socket = ProcessBot::ControlSocket.new(options: options, process: self)
|
73
81
|
@control_socket.start
|
@@ -88,15 +96,26 @@ class ProcessBot::Process
|
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
91
|
-
def
|
99
|
+
def stop(**args)
|
100
|
+
puts "Stop process #{args}"
|
92
101
|
@stopped = true
|
102
|
+
handler_instance.stop
|
93
103
|
end
|
94
104
|
|
95
105
|
def run
|
96
|
-
runner = ProcessBot::Process::Runner.new(command: handler_instance.start_command, logger: logger, options: options)
|
97
106
|
runner.run
|
98
107
|
end
|
99
108
|
|
109
|
+
def runner
|
110
|
+
@runner ||= ProcessBot::Process::Runner.new(
|
111
|
+
command: handler_instance.start_command,
|
112
|
+
handler_name: handler_name,
|
113
|
+
handler_instance: handler_instance,
|
114
|
+
logger: logger,
|
115
|
+
options: options
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
100
119
|
def update_process_title
|
101
120
|
process_args = {application: options[:application], handler: handler_name, id: options[:id], pid: current_pid, port: port}
|
102
121
|
@current_process_title = "ProcessBot #{JSON.generate(process_args)}"
|
data/lib/process_bot/version.rb
CHANGED
data/process_bot.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
25
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
26
|
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
-
|
27
|
+
f.match(%r{\A(?:(?:bin|pkg|test|spec|features)/|\.(?:git|github|travis|circleci)|appveyor)})
|
28
28
|
end
|
29
29
|
end
|
30
30
|
spec.bindir = "exe"
|
@@ -32,6 +32,10 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
34
|
spec.add_dependency "knjrbfw", ">= 0.0.116"
|
35
|
+
spec.add_dependency "pry"
|
36
|
+
spec.add_dependency "rake"
|
37
|
+
spec.add_dependency "rspec"
|
38
|
+
spec.add_dependency "string-cases"
|
35
39
|
|
36
40
|
spec.metadata["rubygems_mfa_required"] = "true"
|
37
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: process_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: knjrbfw
|
@@ -24,6 +23,62 @@ dependencies:
|
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: 0.0.116
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: pry
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: rake
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: rspec
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: string-cases
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
type: :runtime
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
27
82
|
description: Run and control processes.
|
28
83
|
email:
|
29
84
|
- k@spernj.org
|
@@ -44,6 +99,7 @@ files:
|
|
44
99
|
- exe/process_bot
|
45
100
|
- lib/process_bot.rb
|
46
101
|
- lib/process_bot/capistrano.rb
|
102
|
+
- lib/process_bot/capistrano/custom.rake
|
47
103
|
- lib/process_bot/capistrano/puma.rake
|
48
104
|
- lib/process_bot/capistrano/puma.rb
|
49
105
|
- lib/process_bot/capistrano/puma/common.rb
|
@@ -56,12 +112,12 @@ files:
|
|
56
112
|
- lib/process_bot/options.rb
|
57
113
|
- lib/process_bot/process.rb
|
58
114
|
- lib/process_bot/process/handlers.rb
|
115
|
+
- lib/process_bot/process/handlers/custom.rb
|
59
116
|
- lib/process_bot/process/handlers/sidekiq.rb
|
60
117
|
- lib/process_bot/process/runner.rb
|
61
118
|
- lib/process_bot/version.rb
|
62
119
|
- peak_flow.yml
|
63
120
|
- process_bot.gemspec
|
64
|
-
- sig/process_bot.rbs
|
65
121
|
homepage: https://github.com/kaspernj/process_bot
|
66
122
|
licenses:
|
67
123
|
- MIT
|
@@ -71,7 +127,6 @@ metadata:
|
|
71
127
|
source_code_uri: https://github.com/kaspernj/process_bot
|
72
128
|
changelog_uri: https://github.com/kaspernj/process_bot/blob/master/CHANGELOG.md
|
73
129
|
rubygems_mfa_required: 'true'
|
74
|
-
post_install_message:
|
75
130
|
rdoc_options: []
|
76
131
|
require_paths:
|
77
132
|
- lib
|
@@ -86,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
141
|
- !ruby/object:Gem::Version
|
87
142
|
version: '0'
|
88
143
|
requirements: []
|
89
|
-
rubygems_version: 3.
|
90
|
-
signing_key:
|
144
|
+
rubygems_version: 3.6.9
|
91
145
|
specification_version: 4
|
92
146
|
summary: Run and control processes.
|
93
147
|
test_files: []
|
data/sig/process_bot.rbs
DELETED