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 +4 -4
- data/bin/srv +2 -1
- data/lib/srv_manager/context.rb +2 -2
- data/lib/srv_manager/process.rb +15 -5
- data/lib/srv_manager/service.rb +5 -0
- data/lib/srv_manager/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af39a453d9439c68cf905d5e9c1ffb551cab220f
|
4
|
+
data.tar.gz: 5d0dd7ead6bc0679f1b55838f3f0d0fd1fc9a5bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/srv_manager/context.rb
CHANGED
@@ -41,13 +41,13 @@ module SrvManager
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def self.load
|
44
|
-
LOGGER.
|
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.
|
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
|
data/lib/srv_manager/process.rb
CHANGED
@@ -16,15 +16,17 @@ module SrvManager
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def stop
|
19
|
-
|
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
|
data/lib/srv_manager/service.rb
CHANGED
data/lib/srv_manager/version.rb
CHANGED
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.
|
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-
|
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.
|
112
|
+
rubygems_version: 2.0.3
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Service admin and monitor
|