zk-server 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ module ZK
|
|
7
7
|
# By default, we will create a directory in the current working directory called 'zk-server'
|
8
8
|
# to store our data under (configurable).
|
9
9
|
#
|
10
|
-
class
|
10
|
+
class SubProcess < Base
|
11
11
|
attr_reader :exit_status
|
12
12
|
|
13
13
|
# how long should we wait for the child to start responding to 'ruok'?
|
@@ -24,7 +24,7 @@ module ZK
|
|
24
24
|
|
25
25
|
# true if the process was started and is still running
|
26
26
|
def running?
|
27
|
-
spawned? and !@exit_status and
|
27
|
+
spawned? and !@exit_status and false|Process.kill(0, @pid)
|
28
28
|
rescue Errno::ESRCH
|
29
29
|
false
|
30
30
|
end
|
@@ -46,7 +46,7 @@ module ZK
|
|
46
46
|
return unless running? # jruby doesn't seem to get @exit_status ?
|
47
47
|
|
48
48
|
begin
|
49
|
-
|
49
|
+
Process.kill(signal, @pid)
|
50
50
|
rescue Errno::ESRCH
|
51
51
|
return true
|
52
52
|
end
|
@@ -99,7 +99,7 @@ module ZK
|
|
99
99
|
protected
|
100
100
|
def spawn_exit_watching_thread
|
101
101
|
@exit_watching_thread ||= Thread.new do
|
102
|
-
_, @exit_status =
|
102
|
+
_, @exit_status = Process.wait2(@pid)
|
103
103
|
@mutex.synchronize do
|
104
104
|
@exit_cond.broadcast
|
105
105
|
end
|
data/lib/zk-server/version.rb
CHANGED
data/lib/zk-server.rb
CHANGED
@@ -48,7 +48,7 @@ module ZK
|
|
48
48
|
#
|
49
49
|
# @yield [Config] server config instance if block given
|
50
50
|
def self.new(opts={})
|
51
|
-
|
51
|
+
SubProcess.new(opts).tap do |server|
|
52
52
|
yield server.config if block_given?
|
53
53
|
end
|
54
54
|
end
|
@@ -59,6 +59,11 @@ module ZK
|
|
59
59
|
@server ||= new(opts, &blk).tap { |s| s.run }
|
60
60
|
end
|
61
61
|
|
62
|
+
# a singleton server instance (if start was called)
|
63
|
+
def self.server
|
64
|
+
@server
|
65
|
+
end
|
66
|
+
|
62
67
|
def self.shutdown
|
63
68
|
@server and @server.shutdown
|
64
69
|
end
|
@@ -117,8 +122,8 @@ end
|
|
117
122
|
require 'zk-server/version'
|
118
123
|
require 'zk-server/logging'
|
119
124
|
require 'zk-server/config'
|
120
|
-
require 'zk-server/
|
121
|
-
require 'zk-server/
|
125
|
+
require 'zk-server/base'
|
126
|
+
require 'zk-server/sub_process'
|
122
127
|
|
123
128
|
# if defined?(::JRUBY_VERSION)
|
124
129
|
# require 'zk-server/java_embedded'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zk-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 1
|
10
|
+
version: 0.9.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jonathan D. Simms
|
@@ -84,11 +84,11 @@ files:
|
|
84
84
|
- README.md
|
85
85
|
- Rakefile
|
86
86
|
- lib/zk-server.rb
|
87
|
+
- lib/zk-server/base.rb
|
87
88
|
- lib/zk-server/config.rb
|
88
89
|
- lib/zk-server/log4j.properties
|
89
90
|
- lib/zk-server/logging.rb
|
90
|
-
- lib/zk-server/
|
91
|
-
- lib/zk-server/server.rb
|
91
|
+
- lib/zk-server/sub_process.rb
|
92
92
|
- lib/zk-server/version.rb
|
93
93
|
- spec/spec_helper.rb
|
94
94
|
- spec/zk-server/process_spec.rb
|