procodile 1.0.0 → 1.0.1
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/lib/procodile/cli.rb +16 -6
- data/lib/procodile/control_client.rb +10 -6
- data/lib/procodile/instance.rb +5 -5
- data/lib/procodile/process.rb +7 -0
- data/lib/procodile/supervisor.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af875e102a349ee27e1ae2e73f91b4f49c7e6c04
|
4
|
+
data.tar.gz: 478f4a32e80be0176df34a1365dd27713aa6a417
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 609190d1c60c6eac36ffc008d9f8c12fe61164a1820db57e70b60de520e7e10cbb0a730799677227f47f2ecfaafba601a9f360131b327e04491c0ab4130ca3b7
|
7
|
+
data.tar.gz: 2d11514410c07c3f0bc59ccc79a0547692b4914bd189d030fa54ef0296b2d73b4298702440087af4d5431169154c0b8e6e3b0cc500310fabbd39549ce4a146f9
|
data/lib/procodile/cli.rb
CHANGED
@@ -122,12 +122,22 @@ module Procodile
|
|
122
122
|
puts "||".color(process['log_color']) + " Command " + process['command']
|
123
123
|
puts "||".color(process['log_color']) + " Respawning " + "#{process['max_respawns']} every #{process['respawn_window']} seconds"
|
124
124
|
puts "||".color(process['log_color']) + " Restart mode " + process['restart_mode']
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
125
|
+
puts "||".color(process['log_color']) + " Log path " + (process['log_path'] || "none specified")
|
126
|
+
instances = stats['instances'][process['name']]
|
127
|
+
if instances.empty?
|
128
|
+
puts "||".color(process['log_color']) + " No processes running."
|
129
|
+
else
|
130
|
+
instances.each do |instance|
|
131
|
+
print "|| ".color(process['log_color']) + instance['description'].to_s.ljust(20, ' ').color(process['log_color'])
|
132
|
+
if instance['running']
|
133
|
+
print ' Running '.color("42;37")
|
134
|
+
else
|
135
|
+
print ' Stopped '.color("41;37")
|
136
|
+
end
|
137
|
+
print " pid " + instance['pid'].to_s.ljust(12, ' ')
|
138
|
+
print instance['respawns'].to_s + " respawns"
|
139
|
+
puts
|
140
|
+
end
|
131
141
|
end
|
132
142
|
end
|
133
143
|
else
|
@@ -24,15 +24,19 @@ module Procodile
|
|
24
24
|
|
25
25
|
def run(command, options = {})
|
26
26
|
@socket.puts("#{command} #{options.to_json}")
|
27
|
-
|
28
|
-
|
29
|
-
if
|
30
|
-
|
27
|
+
if data = @socket.gets
|
28
|
+
code, reply = data.strip.split(/\s+/, 2)
|
29
|
+
if code.to_i == 200
|
30
|
+
if reply && reply.length > 0
|
31
|
+
JSON.parse(reply)
|
32
|
+
else
|
33
|
+
true
|
34
|
+
end
|
31
35
|
else
|
32
|
-
|
36
|
+
raise Error, "Error from control server: #{code} (#{reply.inspect})"
|
33
37
|
end
|
34
38
|
else
|
35
|
-
raise Error,
|
39
|
+
raise Error ,"Control server disconnected."
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
data/lib/procodile/instance.rb
CHANGED
@@ -108,8 +108,8 @@ module Procodile
|
|
108
108
|
@stopping = true
|
109
109
|
update_pid
|
110
110
|
if self.running?
|
111
|
-
Procodile.log(@process.log_color, description, "Sending
|
112
|
-
::Process.kill(
|
111
|
+
Procodile.log(@process.log_color, description, "Sending #{@process.term_signal} to #{@pid}")
|
112
|
+
::Process.kill(@process.term_signal, pid)
|
113
113
|
else
|
114
114
|
Procodile.log(@process.log_color, description, "Process already stopped")
|
115
115
|
end
|
@@ -151,8 +151,8 @@ module Procodile
|
|
151
151
|
when 'start-term'
|
152
152
|
old_process_pid = @pid
|
153
153
|
start
|
154
|
-
Procodile.log(@process.log_color, description, "Sent
|
155
|
-
::Process.kill(
|
154
|
+
Procodile.log(@process.log_color, description, "Sent #{@process.term_signal} signal to old PID #{old_process_pid} (forgetting now)")
|
155
|
+
::Process.kill(@process.term_signal, old_process_pid)
|
156
156
|
when 'term-start'
|
157
157
|
stop
|
158
158
|
Thread.new do
|
@@ -202,7 +202,7 @@ module Procodile
|
|
202
202
|
add_respawn
|
203
203
|
elsif respawns >= @process.max_respawns
|
204
204
|
Procodile.log(@process.log_color, description, "\e[41;37mWarning:\e[0m\e[31m this process has been respawned #{respawns} times and keeps dying.\e[0m")
|
205
|
-
Procodile.log(@process.log_color, description, "It will not be respawned automatically any longer and will no longer be managed."
|
205
|
+
Procodile.log(@process.log_color, description, "It will not be respawned automatically any longer and will no longer be managed.".color(31))
|
206
206
|
tidy
|
207
207
|
unmonitor
|
208
208
|
end
|
data/lib/procodile/process.rb
CHANGED
@@ -46,6 +46,13 @@ module Procodile
|
|
46
46
|
@options['log_path'] ? File.expand_path(@options['log_path'], @config.root) : nil
|
47
47
|
end
|
48
48
|
|
49
|
+
#
|
50
|
+
# Return the signal to send to terminate the process
|
51
|
+
#
|
52
|
+
def term_signal
|
53
|
+
@options['term_signal'] || 'TERM'
|
54
|
+
end
|
55
|
+
|
49
56
|
#
|
50
57
|
# Defines how this process should be restarted
|
51
58
|
#
|
data/lib/procodile/supervisor.rb
CHANGED
@@ -37,7 +37,7 @@ module Procodile
|
|
37
37
|
Array.new.tap do |instances_started|
|
38
38
|
@config.processes.each do |name, process|
|
39
39
|
next if types && !types.include?(name.to_s) # Not a process we want
|
40
|
-
next if @processes.
|
40
|
+
next if @processes[process] && !@processes[process].empty? # Process type already running
|
41
41
|
instances = start_instances(process.generate_instances)
|
42
42
|
instances_started.push(*instances)
|
43
43
|
end
|
@@ -117,7 +117,7 @@ module Procodile
|
|
117
117
|
end
|
118
118
|
|
119
119
|
# If the processes go away, we can stop the supervisor now
|
120
|
-
if @processes.size == 0
|
120
|
+
if @processes.all? { |_,instances| instances.size == 0 }
|
121
121
|
Procodile.log nil, "system", "All processes have stopped"
|
122
122
|
stop_supervisor
|
123
123
|
end
|
@@ -185,7 +185,7 @@ module Procodile
|
|
185
185
|
def remove_unmonitored_instances
|
186
186
|
@processes.each do |_, instances|
|
187
187
|
instances.reject!(&:unmonitored?)
|
188
|
-
end
|
188
|
+
end
|
189
189
|
end
|
190
190
|
|
191
191
|
def remove_stopped_instances
|
@@ -198,7 +198,7 @@ module Procodile
|
|
198
198
|
false
|
199
199
|
end
|
200
200
|
end
|
201
|
-
end
|
201
|
+
end
|
202
202
|
end
|
203
203
|
|
204
204
|
def process_names_to_instances(names)
|