daemonizer 0.4.8 → 0.4.9

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.8
1
+ 0.4.9
data/daemonizer.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{daemonizer}
8
- s.version = "0.4.8"
8
+ s.version = "0.4.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gleb Pomykalov"]
@@ -98,11 +98,11 @@ module Daemonizer
98
98
  return true
99
99
  end
100
100
 
101
- desc "stat", "Pools statistics"
102
- def stat(pool_name = nil)
103
- statistics = Daemonizer::Stats::MemoryStats.new
101
+ desc "stats", "Pools statistics"
102
+ def stats(pool_name = nil)
104
103
  Daemonizer.find_pools(pool_name).each do |pool|
105
- statistics.print(pool.name.to_s)
104
+ statistics = Daemonizer::Stats::MemoryStats.new(pool)
105
+ statistics.print
106
106
  end
107
107
  end
108
108
 
@@ -132,11 +132,33 @@ module Daemonizer::Stats
132
132
  end
133
133
  end
134
134
 
135
- def print(pool_name)
135
+ attr_reader :pool
136
+
137
+ def initialize(pool)
138
+ @pool = pool
139
+ end
140
+
141
+ def find_all_processes
142
+ find_monitor + find_workers
143
+ end
144
+
145
+ def find_workers
146
+ self.list_processes(:match => /#{@pool.name} worker: instance \d{1,}/)
147
+ end
148
+
149
+ def find_monitor
150
+ self.list_processes(:match => /#{@pool.name} monitor/)
151
+ end
152
+
153
+ def print
136
154
  puts
137
- pool_processes = list_processes(:match =>
138
- /(#{pool_name} worker: instance \d{1,}|#{pool_name} monitor)/)
139
- print_process_list("#{pool_name} processes", pool_processes, :show_ppid => false)
155
+ pool_processes = find_all_processes
156
+ if pool_processes.size == 0
157
+ puts "*** It seems like pool '#{@pool.name}' is not running"
158
+ return
159
+ end
160
+ puts
161
+ print_process_list("#{@pool.name} processes", pool_processes, :show_ppid => false)
140
162
 
141
163
  if RUBY_PLATFORM !~ /linux/
142
164
  puts
@@ -148,7 +170,7 @@ module Daemonizer::Stats
148
170
  "private dirty RSS of processes cannot be determined."
149
171
  end
150
172
  end
151
-
173
+
152
174
  # Returns a list of Process objects that match the given search criteria.
153
175
  #
154
176
  # # Search by executable path.
@@ -224,6 +246,7 @@ module Daemonizer::Stats
224
246
  end
225
247
 
226
248
  private
249
+
227
250
  def platform_provides_private_dirty_rss_information?
228
251
  return RUBY_PLATFORM =~ /linux/
229
252
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemonizer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 8
10
- version: 0.4.8
9
+ - 9
10
+ version: 0.4.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gleb Pomykalov