serverengine 2.0.0pre2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/serverengine/daemon.rb +0 -1
- data/lib/serverengine/version.rb +1 -1
- data/spec/multi_spawn_server_spec.rb +26 -0
- data/spec/server_worker_context.rb +31 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f113bd0243d7ab01e1ee3256f159ca24e3fcaaf
|
4
|
+
data.tar.gz: 98700347259e4cdd7884fd86b4875944ad6f922d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 602df54ace3a99dff2557c4bf450cf57528dc8f080c0b1674c77978074620320ca8dec4a1f0c351c09e9731cf8fbf8dc7a2152736d4e90169e00141eb805dee6
|
7
|
+
data.tar.gz: bac416916a5270e51bf4cc39cc34c697e86d33821597b93d832d865ad2edcddc39a827ed9659ad14b02ac0c5af7870c2972d00e887adc511e6625333d9e9dd2f
|
data/lib/serverengine/daemon.rb
CHANGED
@@ -52,7 +52,6 @@ module ServerEngine
|
|
52
52
|
@chumask = @config[:chumask]
|
53
53
|
|
54
54
|
@pid = nil
|
55
|
-
@command_pipe = @config.fetch(:command_pipe, nil)
|
56
55
|
@command_sender = @config.fetch(:command_sender, ServerEngine.windows? ? "pipe" : "signal")
|
57
56
|
if @command_sender == "pipe"
|
58
57
|
extend ServerEngine::CommandSender::Pipe
|
data/lib/serverengine/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
3
|
+
describe ServerEngine::MultiSpawnServer do
|
4
|
+
include_context 'test server and worker'
|
5
|
+
|
6
|
+
context 'with command_sender=pipe' do
|
7
|
+
it 'starts worker processes' do
|
8
|
+
config = {workers: 2, command_sender: 'pipe', log_stdout: false, log_stderr: false}
|
9
|
+
|
10
|
+
s = ServerEngine::MultiSpawnServer.new(TestWorker) { config.dup }
|
11
|
+
t = Thread.new { s.main }
|
12
|
+
|
13
|
+
begin
|
14
|
+
wait_for_fork
|
15
|
+
|
16
|
+
Timeout.timeout(5) do
|
17
|
+
sleep(0.5) until test_state(:worker_run) == 2
|
18
|
+
end
|
19
|
+
test_state(:worker_run).should == 2
|
20
|
+
ensure
|
21
|
+
s.stop(true)
|
22
|
+
t.join
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -151,7 +151,7 @@ end
|
|
151
151
|
module TestWorker
|
152
152
|
def initialize
|
153
153
|
incr_test_state :worker_initialize
|
154
|
-
@stop_flag = BlockingFlag.new
|
154
|
+
@stop_flag = ServerEngine::BlockingFlag.new
|
155
155
|
end
|
156
156
|
|
157
157
|
def before_fork
|
@@ -180,6 +180,36 @@ module TestWorker
|
|
180
180
|
def after_start
|
181
181
|
incr_test_state :worker_after_start
|
182
182
|
end
|
183
|
+
|
184
|
+
def spawn(pm)
|
185
|
+
script = <<-EOF
|
186
|
+
class WorkerClass
|
187
|
+
include TestWorker
|
188
|
+
def run
|
189
|
+
Thread.new do
|
190
|
+
command_pipe = STDIN.dup
|
191
|
+
STDIN.reopen(File::NULL)
|
192
|
+
Thread.new do
|
193
|
+
until @stop_flag.set?
|
194
|
+
cmd = command_pipe.gets.chomp
|
195
|
+
case cmd
|
196
|
+
when "GRACEFUL_STOP", "IMMEDIATE_STOP"
|
197
|
+
stop
|
198
|
+
when "RELOAD"
|
199
|
+
reload
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
super
|
205
|
+
end
|
206
|
+
end
|
207
|
+
$state_file_mutex = Mutex.new
|
208
|
+
WorkerClass.new.run
|
209
|
+
EOF
|
210
|
+
cmdline = [ServerEngine.ruby_bin_path] + %w[-rbundler/setup -rrspec -I. -Ispec -rserverengine -r] + [__FILE__] + %w[-e] + [script]
|
211
|
+
pm.spawn(*cmdline)
|
212
|
+
end
|
183
213
|
end
|
184
214
|
|
185
215
|
module RunErrorWorker
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverengine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sigdump
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- spec/daemon_logger_spec.rb
|
129
129
|
- spec/daemon_spec.rb
|
130
130
|
- spec/multi_process_server_spec.rb
|
131
|
+
- spec/multi_spawn_server_spec.rb
|
131
132
|
- spec/server_worker_context.rb
|
132
133
|
- spec/signal_thread_spec.rb
|
133
134
|
- spec/socket_manager_spec.rb
|
@@ -148,9 +149,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
149
|
version: 2.1.0
|
149
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
151
|
requirements:
|
151
|
-
- - "
|
152
|
+
- - ">="
|
152
153
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
154
|
+
version: '0'
|
154
155
|
requirements: []
|
155
156
|
rubyforge_project:
|
156
157
|
rubygems_version: 2.5.1
|
@@ -162,6 +163,7 @@ test_files:
|
|
162
163
|
- spec/daemon_logger_spec.rb
|
163
164
|
- spec/daemon_spec.rb
|
164
165
|
- spec/multi_process_server_spec.rb
|
166
|
+
- spec/multi_spawn_server_spec.rb
|
165
167
|
- spec/server_worker_context.rb
|
166
168
|
- spec/signal_thread_spec.rb
|
167
169
|
- spec/socket_manager_spec.rb
|