srv_manager 0.0.5 → 0.0.6

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: 437563702512cd5232a464dd34613f2d9666f569
4
- data.tar.gz: 210427676d2042a5c78fab487b637795ae4889c0
3
+ metadata.gz: af39a453d9439c68cf905d5e9c1ffb551cab220f
4
+ data.tar.gz: 5d0dd7ead6bc0679f1b55838f3f0d0fd1fc9a5bc
5
5
  SHA512:
6
- metadata.gz: efa6121b4e8303d7b1743d20e10ce8da11b47d2cd71b8c3dd78e27072f94f2d3d6b87ebcfade6e37aca4ddfa47a8e7e0fc34c1992453de5b8d8f970a3f391ee2
7
- data.tar.gz: f128851de90230289a08d436bc88507f63c1886c50cb31d4cf49d21bdd99451d4c91763c9530c4ac654aebba477bf07ea173b54cbd787da35707e5dd11f0f9a5
6
+ metadata.gz: a302f485c2b8f98c6961d89d1e1014918e55aa080902425ebff9f1efcc42e3d807ab18b64f3ff9d423ae63e8aecf50f25c77c300af79b72ed99b577de867120d
7
+ data.tar.gz: 2ae906f457c4169808aa65b981dc8cf9fd30f6b13b4ac839ccfca48058aa4ed70e08ed4e0d16d517d030ec4e1a834831ebc956b8019efcb0b43326f8cebbce84
data/bin/srv CHANGED
@@ -46,11 +46,12 @@ module SrvManager
46
46
  end
47
47
  end
48
48
 
49
+ option :kill, type: :boolean
49
50
  desc 'stop <NAME>', 'Stop service'
50
51
  def stop(name)
51
52
  Context.scoped(safe: true) do |ctx|
52
53
  service = find_service name, ctx
53
- service.stop
54
+ options[:kill] ? service.kill : service.stop
54
55
  end
55
56
  end
56
57
 
@@ -41,13 +41,13 @@ module SrvManager
41
41
  private
42
42
 
43
43
  def self.load
44
- LOGGER.info "Reading context from #{data_file}"
44
+ LOGGER.debug "Reading context from #{data_file}"
45
45
  return new unless File.exists? data_file
46
46
  Marshal.load(File.read(data_file))
47
47
  end
48
48
 
49
49
  def self.save(context)
50
- LOGGER.info "Saving context to #{data_file}"
50
+ LOGGER.debug "Saving context to #{data_file}"
51
51
  FileUtils.mkpath File.dirname(data_file) unless Dir.exists? File.dirname(data_file)
52
52
  File.write data_file, Marshal.dump(context)
53
53
  end
@@ -16,15 +16,17 @@ module SrvManager
16
16
  end
17
17
 
18
18
  def stop
19
- return unless started?
20
- begin
21
- ::Process.kill 'TERM', @id
22
- rescue Errno::ESRCH
23
- end
19
+ send_signal 'TERM'
24
20
  LOGGER.info "Stoped process #{@id}"
25
21
  @id = nil
26
22
  end
27
23
 
24
+ def kill
25
+ send_signal 'KILL'
26
+ LOGGER.info "Killed process #{@id}"
27
+ @id = nil
28
+ end
29
+
28
30
  def restart
29
31
  stop if alive?
30
32
  start
@@ -62,6 +64,14 @@ module SrvManager
62
64
  @id = wait_for_pid pid_file, true
63
65
  end
64
66
 
67
+ def send_signal(signal)
68
+ return unless alive?
69
+ begin
70
+ ::Process.kill signal, @id
71
+ rescue Errno::ESRCH
72
+ end
73
+ end
74
+
65
75
  def wait_for_pid(filename, delete=false)
66
76
  Timeout.timeout(60) do
67
77
  loop do
@@ -28,6 +28,11 @@ module SrvManager
28
28
  LOGGER.info "Stoped service #{name}"
29
29
  end
30
30
 
31
+ def kill
32
+ processes.each(&:kill)
33
+ LOGGER.info "Killed service #{name}"
34
+ end
35
+
31
36
  def restart
32
37
  processes.each(&:restart)
33
38
  end
@@ -1,3 +1,3 @@
1
1
  module SrvManager
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: srv_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-02 00:00:00.000000000 Z
11
+ date: 2013-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.1.10
112
+ rubygems_version: 2.0.3
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Service admin and monitor