arya-mongrel_proctitle 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongrel_proctitle.rb +13 -2
- metadata +1 -1
data/lib/mongrel_proctitle.rb
CHANGED
@@ -12,6 +12,8 @@ module Mongrel
|
|
12
12
|
@request_threads = []
|
13
13
|
@queue_length = 0
|
14
14
|
@request_count = 0
|
15
|
+
@last_request_finished_in = nil
|
16
|
+
@last_request_finished_at = Time.now.to_f
|
15
17
|
@updater_thread = Thread.new do
|
16
18
|
while true
|
17
19
|
@mutex.synchronize do
|
@@ -49,6 +51,8 @@ module Mongrel
|
|
49
51
|
mutex.synchronize do
|
50
52
|
@queue_length -= 1
|
51
53
|
@request_count += 1
|
54
|
+
@last_request_finished_in = Time.now.to_f - Thread.current[:arrived_at]
|
55
|
+
@last_request_finished_at = Time.now.to_f
|
52
56
|
@request_threads.delete(Thread.current)
|
53
57
|
set_request_list_title
|
54
58
|
end
|
@@ -78,14 +82,21 @@ module Mongrel
|
|
78
82
|
"%.1fs" % delta
|
79
83
|
elsif delta < 3600
|
80
84
|
"#{delta.to_i / 60}m#{delta.to_i % 60}s"
|
81
|
-
|
85
|
+
elsif delta < 86400
|
82
86
|
"#{delta.to_i / 3600}h#{(delta.to_i % 3600) / 60}m"
|
87
|
+
else
|
88
|
+
"#{delta.to_i / 86400}d#{(delta.to_i % 86400) / 3600}h"
|
83
89
|
end
|
84
90
|
end
|
85
91
|
|
86
92
|
# Reports process as being idle.
|
87
93
|
def set_idle
|
88
|
-
|
94
|
+
str = "idle"
|
95
|
+
extra = []
|
96
|
+
extra << "last #{time_delta_abbriv(@last_request_finished_in)}" if @last_request_finished_in
|
97
|
+
extra << "idle for #{time_delta_abbriv(Time.now.to_f - @last_request_finished_at)}"
|
98
|
+
str << " [#{extra.join(", ")}]"
|
99
|
+
self.title = str
|
89
100
|
end
|
90
101
|
|
91
102
|
# Reports process as handling a socket.
|