freyr 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ree-1.8.7-2011.03@freyr"
8
+
9
+ #
10
+ # First we attempt to load the desired environment directly from the environment
11
+ # file. This is very fast and efficicent compared to running through the entire
12
+ # CLI and selector. If you want feedback on which environment was used then
13
+ # insert the word 'use' after --create as this triggers verbose mode.
14
+ #
15
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
16
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
17
+ then
18
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
19
+
20
+ if [[ -s ".rvm/hooks/after_use" ]]
21
+ then
22
+ . ".rvm/hooks/after_use"
23
+ fi
24
+ else
25
+ # If the environment file has not yet been created, use the RVM CLI to select.
26
+ if ! rvm --create use "$environment_id"
27
+ then
28
+ echo "Failed to create RVM environment ''."
29
+ fi
30
+ fi
31
+
32
+ #
33
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
34
+ # it be automatically loaded. Uncomment the following and adjust the filename if
35
+ # necessary.
36
+ #
37
+ # filename=".gems"
38
+ # if [[ -s "$filename" ]] ; then
39
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
40
+ # fi
41
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ freyr (0.3.2)
5
+ thor (>= 0.10)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.2)
11
+ git (1.2.5)
12
+ jeweler (1.6.2)
13
+ bundler (~> 1.0)
14
+ git (>= 1.2.5)
15
+ rake
16
+ rake (0.9.2)
17
+ rspec (2.6.0)
18
+ rspec-core (~> 2.6.0)
19
+ rspec-expectations (~> 2.6.0)
20
+ rspec-mocks (~> 2.6.0)
21
+ rspec-core (2.6.4)
22
+ rspec-expectations (2.6.0)
23
+ diff-lcs (~> 1.1.2)
24
+ rspec-mocks (2.6.0)
25
+ thor (0.14.6)
26
+ yard (0.7.1)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ freyr!
33
+ jeweler
34
+ rspec (>= 1.2.9)
35
+ yard
data/Rakefile CHANGED
@@ -12,7 +12,6 @@ begin
12
12
  gem.authors = ["Tal Atlas"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
14
  gem.add_development_dependency "yard", ">= 0"
15
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
15
  gem.add_dependency 'thor', ">= 0.10"
17
16
  end
18
17
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
data/freyr.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{freyr}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tal Atlas"]
12
- s.date = %q{2011-06-09}
12
+ s.date = %q{2011-06-15}
13
13
  s.default_executable = %q{freyr}
14
14
  s.description = %q{Define all services you need to run and this will launch,daemonize,and monitor them for you.}
15
15
  s.email = %q{me@tal.by}
@@ -21,7 +21,10 @@ Gem::Specification.new do |s|
21
21
  s.files = [
22
22
  ".document",
23
23
  ".irbrc",
24
+ ".rvmrc",
24
25
  "Freyrfile",
26
+ "Gemfile",
27
+ "Gemfile.lock",
25
28
  "LICENSE",
26
29
  "README.markdown",
27
30
  "Rakefile",
@@ -36,6 +39,8 @@ Gem::Specification.new do |s|
36
39
  "lib/freyr/cli/monitor.rb",
37
40
  "lib/freyr/command.rb",
38
41
  "lib/freyr/pinger.rb",
42
+ "lib/freyr/process_info.rb",
43
+ "lib/freyr/process_info_list.rb",
39
44
  "lib/freyr/service.rb",
40
45
  "lib/freyr/service_group.rb",
41
46
  "lib/freyr/service_info.rb",
@@ -45,26 +50,52 @@ Gem::Specification.new do |s|
45
50
  ]
46
51
  s.homepage = %q{http://github.com/Talby/freyr}
47
52
  s.require_paths = ["lib"]
48
- s.rubygems_version = %q{1.5.0}
53
+ s.rubygems_version = %q{1.6.2}
49
54
  s.summary = %q{Service manager and runner}
50
- s.test_files = [
51
- "spec/freyr_spec.rb",
52
- "spec/spec_helper.rb"
53
- ]
54
55
 
55
56
  if s.respond_to? :specification_version then
56
57
  s.specification_version = 3
57
58
 
58
59
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
60
+ s.add_runtime_dependency(%q<freyr>, [">= 0"])
61
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
62
+ s.add_development_dependency(%q<yard>, [">= 0"])
63
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
64
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
65
+ s.add_development_dependency(%q<yard>, [">= 0"])
66
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
67
+ s.add_development_dependency(%q<yard>, [">= 0"])
68
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
69
+ s.add_development_dependency(%q<yard>, [">= 0"])
59
70
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
60
71
  s.add_development_dependency(%q<yard>, [">= 0"])
61
72
  s.add_runtime_dependency(%q<thor>, [">= 0.10"])
62
73
  else
74
+ s.add_dependency(%q<freyr>, [">= 0"])
75
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
76
+ s.add_dependency(%q<yard>, [">= 0"])
77
+ s.add_dependency(%q<jeweler>, [">= 0"])
78
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
79
+ s.add_dependency(%q<yard>, [">= 0"])
80
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
81
+ s.add_dependency(%q<yard>, [">= 0"])
82
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
83
+ s.add_dependency(%q<yard>, [">= 0"])
63
84
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
64
85
  s.add_dependency(%q<yard>, [">= 0"])
65
86
  s.add_dependency(%q<thor>, [">= 0.10"])
66
87
  end
67
88
  else
89
+ s.add_dependency(%q<freyr>, [">= 0"])
90
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
91
+ s.add_dependency(%q<yard>, [">= 0"])
92
+ s.add_dependency(%q<jeweler>, [">= 0"])
93
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
94
+ s.add_dependency(%q<yard>, [">= 0"])
95
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
96
+ s.add_dependency(%q<yard>, [">= 0"])
97
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
98
+ s.add_dependency(%q<yard>, [">= 0"])
68
99
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
69
100
  s.add_dependency(%q<yard>, [">= 0"])
70
101
  s.add_dependency(%q<thor>, [">= 0.10"])
@@ -79,6 +79,19 @@ module Freyr
79
79
  str << ' '*'(123)'.size
80
80
  end
81
81
 
82
+ if args[:procinfo]
83
+ begin
84
+ @proc_list ||= ProcessInfoList.new
85
+
86
+ pid = s.command.pid
87
+
88
+ proc = @proc_list[pid.to_i]
89
+
90
+ str << " CPU: #{proc.cpu}% - MEM: #{proc.mem}%" if proc
91
+ rescue => e
92
+ end
93
+ end
94
+
82
95
  str << "\n" #if str =~ /\s$/ # Thor's display only adds a new line if the last char isn't a space
83
96
 
84
97
  strs << str
@@ -3,8 +3,9 @@ module Freyr
3
3
 
4
4
  desc 'list', 'lists all available services:'
5
5
  method_option :ping, :type => :boolean, :default => false, :aliases => '-p', :desc => 'also ping each service which can ping'
6
+ method_option :info, :type => :boolean, :default => false, :aliases => '-i', :desc => 'also get cpu and memory info'
6
7
  def list
7
- strs = list_all_services(:ping => options.ping?)
8
+ strs = list_all_services(:ping => options.ping?, :procinfo => options.info?)
8
9
 
9
10
  if strs.empty?
10
11
  say "No services available", :red
@@ -0,0 +1,5 @@
1
+ module Freyr
2
+ class ProcessInfo
3
+ attr_accessor :user, :pid, :cpu, :mem, :vsz, :rss, :tt, :stat, :started, :time, :cmd
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ module Freyr
2
+ class ProcessInfoList
3
+ def initialize
4
+ ps = `ps aux`.chomp.split("\n")
5
+ ps.shift
6
+
7
+ @processes = {}
8
+ ps.each do |proc|
9
+ proc = proc.split(/\s+/)
10
+ p = ProcessInfo.new
11
+ p.user = proc.shift
12
+ p.pid = proc.shift
13
+ p.cpu = proc.shift
14
+ p.mem = proc.shift
15
+ p.vsz = proc.shift
16
+ p.rss = proc.shift
17
+ p.tt = proc.shift
18
+ p.stat = proc.shift
19
+ p.started = proc.shift
20
+ p.time = proc.shift
21
+ p.cmd = proc.join(' ')
22
+
23
+ @processes[p.pid.to_i] = p
24
+ end
25
+ end
26
+
27
+ def [] pid
28
+ @processes[pid.to_i]
29
+ end
30
+
31
+ end
32
+ end
data/lib/freyr.rb CHANGED
@@ -4,6 +4,6 @@ module Freyr
4
4
  VERSION = File.open(File.expand_path(File.dirname(__FILE__)+'/../VERSION')).read
5
5
  end
6
6
 
7
- %w{service_info service_group service command pinger}.each do |f|
7
+ %w{service_info service_group service command pinger process_info process_info_list}.each do |f|
8
8
  require File.expand_path(File.dirname(__FILE__)+"/freyr/#{f}.rb")
9
9
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freyr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tal Atlas
@@ -15,13 +15,70 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-09 00:00:00 -04:00
18
+ date: 2011-06-15 00:00:00 -04:00
19
19
  default_executable: freyr
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ name: freyr
33
+ version_requirements: *id001
34
+ prerelease: false
35
+ - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 13
43
+ segments:
44
+ - 1
45
+ - 2
46
+ - 9
47
+ version: 1.2.9
22
48
  name: rspec
49
+ version_requirements: *id002
23
50
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
51
+ - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ name: yard
63
+ version_requirements: *id003
64
+ prerelease: false
65
+ - !ruby/object:Gem::Dependency
66
+ type: :development
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ name: jeweler
77
+ version_requirements: *id004
78
+ prerelease: false
79
+ - !ruby/object:Gem::Dependency
80
+ type: :development
81
+ requirement: &id005 !ruby/object:Gem::Requirement
25
82
  none: false
26
83
  requirements:
27
84
  - - ">="
@@ -32,12 +89,72 @@ dependencies:
32
89
  - 2
33
90
  - 9
34
91
  version: 1.2.9
92
+ name: rspec
93
+ version_requirements: *id005
94
+ prerelease: false
95
+ - !ruby/object:Gem::Dependency
35
96
  type: :development
36
- version_requirements: *id001
97
+ requirement: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ name: yard
107
+ version_requirements: *id006
108
+ prerelease: false
109
+ - !ruby/object:Gem::Dependency
110
+ type: :development
111
+ requirement: &id007 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 13
117
+ segments:
118
+ - 1
119
+ - 2
120
+ - 9
121
+ version: 1.2.9
122
+ name: rspec
123
+ version_requirements: *id007
124
+ prerelease: false
37
125
  - !ruby/object:Gem::Dependency
126
+ type: :development
127
+ requirement: &id008 !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
135
+ version: "0"
38
136
  name: yard
137
+ version_requirements: *id008
39
138
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
139
+ - !ruby/object:Gem::Dependency
140
+ type: :development
141
+ requirement: &id009 !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 13
147
+ segments:
148
+ - 1
149
+ - 2
150
+ - 9
151
+ version: 1.2.9
152
+ name: rspec
153
+ version_requirements: *id009
154
+ prerelease: false
155
+ - !ruby/object:Gem::Dependency
156
+ type: :development
157
+ requirement: &id010 !ruby/object:Gem::Requirement
41
158
  none: false
42
159
  requirements:
43
160
  - - ">="
@@ -46,12 +163,42 @@ dependencies:
46
163
  segments:
47
164
  - 0
48
165
  version: "0"
166
+ name: yard
167
+ version_requirements: *id010
168
+ prerelease: false
169
+ - !ruby/object:Gem::Dependency
49
170
  type: :development
50
- version_requirements: *id002
171
+ requirement: &id011 !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ hash: 13
177
+ segments:
178
+ - 1
179
+ - 2
180
+ - 9
181
+ version: 1.2.9
182
+ name: rspec
183
+ version_requirements: *id011
184
+ prerelease: false
51
185
  - !ruby/object:Gem::Dependency
52
- name: thor
186
+ type: :development
187
+ requirement: &id012 !ruby/object:Gem::Requirement
188
+ none: false
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ hash: 3
193
+ segments:
194
+ - 0
195
+ version: "0"
196
+ name: yard
197
+ version_requirements: *id012
53
198
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
199
+ - !ruby/object:Gem::Dependency
200
+ type: :runtime
201
+ requirement: &id013 !ruby/object:Gem::Requirement
55
202
  none: false
56
203
  requirements:
57
204
  - - ">="
@@ -61,8 +208,9 @@ dependencies:
61
208
  - 0
62
209
  - 10
63
210
  version: "0.10"
64
- type: :runtime
65
- version_requirements: *id003
211
+ name: thor
212
+ version_requirements: *id013
213
+ prerelease: false
66
214
  description: Define all services you need to run and this will launch,daemonize,and monitor them for you.
67
215
  email: me@tal.by
68
216
  executables:
@@ -75,7 +223,10 @@ extra_rdoc_files:
75
223
  files:
76
224
  - .document
77
225
  - .irbrc
226
+ - .rvmrc
78
227
  - Freyrfile
228
+ - Gemfile
229
+ - Gemfile.lock
79
230
  - LICENSE
80
231
  - README.markdown
81
232
  - Rakefile
@@ -90,6 +241,8 @@ files:
90
241
  - lib/freyr/cli/monitor.rb
91
242
  - lib/freyr/command.rb
92
243
  - lib/freyr/pinger.rb
244
+ - lib/freyr/process_info.rb
245
+ - lib/freyr/process_info_list.rb
93
246
  - lib/freyr/service.rb
94
247
  - lib/freyr/service_group.rb
95
248
  - lib/freyr/service_info.rb
@@ -126,10 +279,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
279
  requirements: []
127
280
 
128
281
  rubyforge_project:
129
- rubygems_version: 1.5.0
282
+ rubygems_version: 1.6.2
130
283
  signing_key:
131
284
  specification_version: 3
132
285
  summary: Service manager and runner
133
- test_files:
134
- - spec/freyr_spec.rb
135
- - spec/spec_helper.rb
286
+ test_files: []
287
+