arya-mongrel_proctitle 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongrel_proctitle.rb +16 -5
- metadata +1 -1
data/lib/mongrel_proctitle.rb
CHANGED
@@ -12,8 +12,11 @@ module Mongrel
|
|
12
12
|
@request_threads = []
|
13
13
|
@queue_length = 0
|
14
14
|
@request_count = 0
|
15
|
-
@last_request_finished_in = nil
|
16
15
|
@last_request_finished_at = Time.now.to_f
|
16
|
+
@last_request_finished_in = nil
|
17
|
+
@last_request_str = nil
|
18
|
+
@slowest_finished_in = nil
|
19
|
+
@slowest_request_str = nil
|
17
20
|
@updater_thread = Thread.new do
|
18
21
|
while true
|
19
22
|
@mutex.synchronize do
|
@@ -51,8 +54,16 @@ module Mongrel
|
|
51
54
|
mutex.synchronize do
|
52
55
|
@queue_length -= 1
|
53
56
|
@request_count += 1
|
57
|
+
|
54
58
|
@last_request_finished_in = Time.now.to_f - Thread.current[:arrived_at]
|
55
59
|
@last_request_finished_at = Time.now.to_f
|
60
|
+
@last_request_str = Thread.current[:request_str]
|
61
|
+
|
62
|
+
if @slowest_finished_in.nil? || @slowest_finished_in < @last_request_finished_in
|
63
|
+
@slowest_finished_in = @last_request_finished_in
|
64
|
+
@slowest_request_str = @last_request_str
|
65
|
+
end
|
66
|
+
|
56
67
|
@request_threads.delete(Thread.current)
|
57
68
|
set_request_list_title
|
58
69
|
end
|
@@ -91,11 +102,11 @@ module Mongrel
|
|
91
102
|
|
92
103
|
# Reports process as being idle.
|
93
104
|
def set_idle
|
94
|
-
str = "idle"
|
105
|
+
str = "idle for #{time_delta_abbriv(Time.now.to_f - @last_request_finished_at)}"
|
95
106
|
extra = []
|
96
|
-
extra << "last #{time_delta_abbriv(@last_request_finished_in)}" if @last_request_finished_in
|
97
|
-
extra << "
|
98
|
-
str << " [#{extra.join(", ")}]"
|
107
|
+
extra << "last #{time_delta_abbriv(@last_request_finished_in)} #{@last_request_str}" if @last_request_finished_in && @last_request_str
|
108
|
+
extra << "slowest #{time_delta_abbriv(@slowest_finished_in)} #{@slowest_request_str}" if @slowest_finished_in && @slowest_request_str
|
109
|
+
str << " [#{extra.join(", ")}]" unless extra.empty?
|
99
110
|
self.title = str
|
100
111
|
end
|
101
112
|
|