datacenter 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99a3accef6b707554c34a137f923ca48ad2f6c21
4
- data.tar.gz: 4d1b56aa1f896624834cd467c21bc0f82078287a
3
+ metadata.gz: 639f19a32af94539eff49e4d60bb416ac5e5366b
4
+ data.tar.gz: f64487b04b2433088d96a99e56aedba41d0e5c33
5
5
  SHA512:
6
- metadata.gz: e4f8c38f8d0e19e2700649f881c8d9d44da264373b853c0996f911814e90afa36bcbbdb6bfa53e106c70689a2999c49011fecf398b43152deaec044fe0e7f9fe
7
- data.tar.gz: 1519b77f585514c3d7cf70726ca808482e6ff311efb4880f446dbece554331709636fd274fb065887c3833e97a860913a9a3fc62526388141acca967862be0d4
6
+ metadata.gz: b9e64261f9c76232c11b0fa84d2222dad389f1211d3d0bdca52299b57ef77118f3db648beb332d4b6b2059a33dca5c9d06028dfbe1ac648a68e84f2798263c88
7
+ data.tar.gz: 15eeae879c23dbfdd764e59ad7f42d8f5c26d859ad76f7ceced266a32f355fa6f43bfd754f50bfcad8b3d11a31b5598d306f2906154168f1fa1b31f3eea4da3e
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby 2.1
1
+ ruby 2.0
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ rvm:
3
3
  - 1.9.3
4
4
  - 2.0
5
5
  - 2.1
6
+ - 2.2
6
7
  - jruby
7
8
  before_install:
8
9
  - sudo apt-get -y install openssh-server
data/datacenter.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency 'net-ssh'
22
+ spec.add_dependency 'class_config'
22
23
 
23
24
  spec.add_development_dependency 'bundler', '~> 1.3'
24
25
  spec.add_development_dependency 'rake'
@@ -30,26 +30,19 @@ module Datacenter
30
30
  end
31
31
 
32
32
  def alive?
33
- shell.run("ls /proc | grep #{pid}") == pid.to_s
33
+ alive = !shell.run("ps -p #{pid} | grep #{pid}").empty?
34
+ Datacenter.logger.debug(self.class) { "pid: #{pid} - ALIVE: #{alive}" } if !alive
35
+ alive
34
36
  end
35
37
 
36
- def stop
37
- send_signal :QUIT if alive?
38
- end
39
-
40
- def kill
41
- send_signal :KILL if alive?
42
- while alive?; end
38
+ def send_signal(signal)
39
+ shell.run "kill -s #{signal} #{pid}"
43
40
  end
44
41
 
45
42
  private
46
43
 
47
44
  attr_reader :shell
48
45
 
49
- def send_signal(signal)
50
- shell.run "kill -s #{signal} #{pid}"
51
- end
52
-
53
46
  def info
54
47
  @cache.fetch(:info) do
55
48
  ps = shell.run('ps aux').scan(/.*#{pid}.*/)[0].split
@@ -1,3 +1,3 @@
1
1
  module Datacenter
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/datacenter.rb CHANGED
@@ -1,4 +1,11 @@
1
1
  require 'net/ssh'
2
2
  require 'open3'
3
+ require 'class_config'
4
+ require 'logger'
5
+
6
+ module Datacenter
7
+ extend ClassConfig
8
+ attr_config :logger, Logger.new('/dev/null')
9
+ end
3
10
 
4
11
  Dir.glob(File.expand_path('datacenter/*.rb', File.dirname(__FILE__))).sort.each { |f| require f }
data/spec/commands.yml CHANGED
@@ -1,8 +1,10 @@
1
- "ls /proc | grep 22803": "22803"
1
+ "ps -p 22803 | grep 22803": "22803"
2
2
 
3
- "ls /proc | grep -22803": ""
3
+ "ps -p -22803 | grep -22803": ""
4
4
 
5
- "kill -s QUIT 22803": ""
5
+ "kill -s QUIT 22803": 'quit success'
6
+
7
+ "kill -s KILL 22803": 'kill success'
6
8
 
7
9
  "uname -i": x86_64
8
10
 
@@ -38,22 +38,6 @@ module Datacenter
38
38
 
39
39
  end
40
40
 
41
- class Kill
42
- def initialize(pid)
43
- @pid = pid
44
- end
45
-
46
- def run(command)
47
- if command == "kill -s 0 #{@pid}"
48
- ''
49
- elsif command == "kill -s KILL #{@pid}"
50
- @pid = nil
51
- ''
52
- else
53
- 'kill: No such process'
54
- end
55
- end
56
- end
57
41
  end
58
42
  end
59
43
 
data/spec/process_spec.rb CHANGED
@@ -11,9 +11,9 @@ describe Datacenter::Process do
11
11
 
12
12
  it ('Dead') { Datacenter::Process.new(-pid, mock_shell).wont_be :alive? }
13
13
 
14
- it ('Stop') { process.stop }
14
+ it ('Quit') { process.send_signal(:QUIT).must_equal 'quit success' }
15
15
 
16
- it ('Kill') { Datacenter::Process.new(pid, Datacenter::Shell::Kill.new(pid)).kill }
16
+ it ('Kill') { process.send_signal(:KILL).must_equal 'kill success' }
17
17
 
18
18
  it ('Name') { process.name.must_equal 'gnome-system-mo' }
19
19
 
metadata CHANGED
@@ -1,111 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datacenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-17 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: class_config
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ~>
32
46
  - !ruby/object:Gem::Version
33
47
  version: '1.3'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ~>
39
53
  - !ruby/object:Gem::Version
40
54
  version: '1.3'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ">="
59
+ - - '>='
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ">="
66
+ - - '>='
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: minitest
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ~>
60
74
  - !ruby/object:Gem::Version
61
75
  version: '4.7'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ~>
67
81
  - !ruby/object:Gem::Version
68
82
  version: '4.7'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: turn
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ~>
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0.9'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ~>
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0.9'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: simplecov
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ">="
101
+ - - '>='
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ">="
108
+ - - '>='
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: pry-nav
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ">="
115
+ - - '>='
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ">="
122
+ - - '>='
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  description: Manage and monitor servers and processes
@@ -115,11 +129,11 @@ executables: []
115
129
  extensions: []
116
130
  extra_rdoc_files: []
117
131
  files:
118
- - ".coveralls.yml"
119
- - ".gitignore"
120
- - ".ruby-gemset"
121
- - ".ruby-version"
122
- - ".travis.yml"
132
+ - .coveralls.yml
133
+ - .gitignore
134
+ - .ruby-gemset
135
+ - .ruby-version
136
+ - .travis.yml
123
137
  - Gemfile
124
138
  - LICENSE.txt
125
139
  - README.md
@@ -150,17 +164,17 @@ require_paths:
150
164
  - lib
151
165
  required_ruby_version: !ruby/object:Gem::Requirement
152
166
  requirements:
153
- - - ">="
167
+ - - '>='
154
168
  - !ruby/object:Gem::Version
155
169
  version: '0'
156
170
  required_rubygems_version: !ruby/object:Gem::Requirement
157
171
  requirements:
158
- - - ">="
172
+ - - '>='
159
173
  - !ruby/object:Gem::Version
160
174
  version: '0'
161
175
  requirements: []
162
176
  rubyforge_project:
163
- rubygems_version: 2.2.2
177
+ rubygems_version: 2.4.3
164
178
  signing_key:
165
179
  specification_version: 4
166
180
  summary: Manage and monitor servers and processes