brown 2.2.1 → 2.2.2
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/bin/brown +20 -18
- 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: 02ab3890a3b264186f6ad050332e0e13f897ec3a
|
4
|
+
data.tar.gz: d9e120a8aa6478c5551c21fc9868e2b2a892a60e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 781654a0fbf0643dbae1b2a481a14b3ca21dd3d58ae3b8ec5c3555c2f2f7bcc4cc9865e9ea4417a125ceba391366052f196f3dd72713a7254a4cddf7496774c0
|
7
|
+
data.tar.gz: 10e4dca65cd6f577ac9f604e3a0678584d9281f0a23863702c03c5013aa67c4f73b8241c26f97c5f7775e836da151948d03853a2d34754b2519e23de0798766b
|
data/bin/brown
CHANGED
@@ -27,6 +27,7 @@ agents = []
|
|
27
27
|
|
28
28
|
def stop_agents(agents)
|
29
29
|
agents.each do |th|
|
30
|
+
Brown::Agent.logger.debug { "Stopping agent #{th[:agent_class].inspect} (thread #{th.inspect})" }
|
30
31
|
th[:agent_class] && th[:agent_class].stop
|
31
32
|
end
|
32
33
|
end
|
@@ -60,6 +61,7 @@ agent_classes.each do |klass|
|
|
60
61
|
agents << th
|
61
62
|
|
62
63
|
Brown::Agent.logger.info { "Started agent #{klass}" }
|
64
|
+
Brown::Agent.logger.debug { "Agent thread is #{th.inspect}" }
|
63
65
|
end
|
64
66
|
|
65
67
|
loop do
|
@@ -67,30 +69,30 @@ loop do
|
|
67
69
|
break
|
68
70
|
end
|
69
71
|
|
72
|
+
sleep 0.5
|
73
|
+
|
70
74
|
agents.each do |th|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
Brown::Agent.logger.info { ex.backtrace.map { |l| " #{l}" }.join("\n") }
|
77
|
-
|
78
|
-
Brown::Agent.logger.info { "Re-starting #{klass} agent" }
|
79
|
-
|
80
|
-
new_th = Thread.new(klass) do |klass|
|
81
|
-
Thread.current[:agent_class] = klass
|
82
|
-
klass.run
|
83
|
-
end
|
84
|
-
|
85
|
-
agents << new_th
|
86
|
-
else
|
87
|
-
Brown::Agent.logger.warn "Agent #{th[:agent_class]} exited cleanly; not restarting"
|
75
|
+
Brown::Agent.logger.debug { "Examining agent thread #{th.inspect}" }
|
76
|
+
begin
|
77
|
+
if th.join(0.5)
|
78
|
+
Brown::Agent.logger.info { "Agent #{th[:agent_class]} exited cleanly; not restarting" }
|
79
|
+
agents.delete(th)
|
88
80
|
end
|
81
|
+
rescue Exception => ex
|
82
|
+
Brown::Agent.logger.fatal { "Agent #{th[:agent_class]} crashed: #{ex.message} (#{ex.class})" }
|
83
|
+
Brown::Agent.logger.info { ex.backtrace.map { |l| " #{l}" }.join("\n") }
|
84
|
+
|
85
|
+
Brown::Agent.logger.info { "Re-starting #{klass} agent" }
|
89
86
|
|
90
87
|
klass = th[:agent_class]
|
91
|
-
th[:agent_class] = nil
|
92
88
|
agents.delete(th)
|
89
|
+
|
90
|
+
agents << Thread.new(klass) do |klass|
|
91
|
+
Thread.current[:agent_class] = klass
|
92
|
+
klass.run
|
93
|
+
end
|
93
94
|
end
|
95
|
+
|
94
96
|
end
|
95
97
|
end
|
96
98
|
|