riser 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/riser/server.rb +49 -23
- data/lib/riser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c9d1d7238c0a2002a16d53c594c40a8f63f8cd29548bd376b59acf280305960
|
4
|
+
data.tar.gz: 3db48c1fffc46fa46af97b479a10737c65c7dcc27690dd7eca85e66897bdd86d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dfeae8c5c37eff1716fee819db62b642d2da12ee692c564e5813085fe8f98b87ad65fed3b041df7e573c43de2154b2cadc9401259d0739ee56c05a6a1ea3780
|
7
|
+
data.tar.gz: e0aeff5527e15469ea7eecfa84d5848a3ad2716a5e30a58b1153790e822e1c5f096d69826aee7c725ecf94221801ca61be989bc9c0c1b39b30ea62e79392b6e2
|
data/lib/riser/server.rb
CHANGED
@@ -218,6 +218,7 @@ module Riser
|
|
218
218
|
@accept = nil
|
219
219
|
@accept_return = nil
|
220
220
|
@dispatch = nil
|
221
|
+
@dispose = nil
|
221
222
|
@stop_state = nil
|
222
223
|
@stat_operation_queue = []
|
223
224
|
end
|
@@ -271,6 +272,11 @@ module Riser
|
|
271
272
|
nil
|
272
273
|
end
|
273
274
|
|
275
|
+
def dispose(&block) # :yields:
|
276
|
+
@dispose = block
|
277
|
+
nil
|
278
|
+
end
|
279
|
+
|
274
280
|
# should be called from signal(2) handler
|
275
281
|
def signal_stop_graceful
|
276
282
|
@stop_state ||= :graceful
|
@@ -279,7 +285,9 @@ module Riser
|
|
279
285
|
|
280
286
|
# should be called from signal(2) handler
|
281
287
|
def signal_stop_forced
|
282
|
-
@stop_state
|
288
|
+
if (! @stop_state || @stop_state == :graceful) then
|
289
|
+
@stop_state = :forced
|
290
|
+
end
|
283
291
|
nil
|
284
292
|
end
|
285
293
|
|
@@ -339,12 +347,16 @@ module Riser
|
|
339
347
|
thread_list << Thread.start(i) {|thread_number|
|
340
348
|
begin
|
341
349
|
Thread.current[:number] = thread_number
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
350
|
+
begin
|
351
|
+
while (socket = queue.pop)
|
352
|
+
begin
|
353
|
+
@dispatch.call(socket)
|
354
|
+
ensure
|
355
|
+
socket.close unless socket.closed?
|
356
|
+
end
|
347
357
|
end
|
358
|
+
ensure
|
359
|
+
@dispose.call
|
348
360
|
end
|
349
361
|
rescue
|
350
362
|
error_lock.synchronize{
|
@@ -379,19 +391,31 @@ module Riser
|
|
379
391
|
queue.close
|
380
392
|
end
|
381
393
|
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
394
|
+
begin
|
395
|
+
done = catch(:retry_stopping) {
|
396
|
+
@at_stop.call(@stop_state)
|
397
|
+
case (@stop_state)
|
398
|
+
when :graceful
|
399
|
+
until (thread_list.empty?)
|
400
|
+
until (thread_list[0].join(@thread_queue_polling_timeout_seconds))
|
401
|
+
if (@stop_state == :forced) then
|
402
|
+
throw(:retry_stopping)
|
403
|
+
end
|
404
|
+
end
|
405
|
+
thread_list.shift
|
406
|
+
end
|
407
|
+
when :forced
|
408
|
+
until (thread_list.empty?)
|
409
|
+
thread_list[0].kill
|
410
|
+
thread_list.shift
|
411
|
+
end
|
412
|
+
else
|
413
|
+
raise "internal error: unknown stop state <#{@stop_state.inspect}>"
|
414
|
+
end
|
415
|
+
|
416
|
+
true
|
417
|
+
}
|
418
|
+
end until (done)
|
395
419
|
ensure
|
396
420
|
@postprocess.call
|
397
421
|
end
|
@@ -553,6 +577,7 @@ module Riser
|
|
553
577
|
}
|
554
578
|
thread_dispatcher.accept_return{ child_io.write(RADY_CMD) }
|
555
579
|
thread_dispatcher.dispatch(&@dispatch)
|
580
|
+
thread_dispatcher.dispose(&NO_CALL)
|
556
581
|
|
557
582
|
Signal.trap(SIGNAL_STOP_GRACEFUL) { thread_dispatcher.signal_stop_graceful }
|
558
583
|
Signal.trap(SIGNAL_STOP_FORCED) { thread_dispatcher.signal_stop_forced }
|
@@ -627,12 +652,12 @@ module Riser
|
|
627
652
|
response = process.io.read(RADY_LEN)
|
628
653
|
response == RADY_CMD or raise "internal error: unknown response <#{response.inspect}>"
|
629
654
|
}
|
630
|
-
@process_dispatcher.
|
631
|
-
|
632
|
-
for process in process_list
|
655
|
+
@process_dispatcher.dispose{
|
656
|
+
process = process_list[Thread.current[:number]]
|
633
657
|
Process.wait(process.pid)
|
634
658
|
process.io.close
|
635
|
-
|
659
|
+
}
|
660
|
+
@process_dispatcher.start
|
636
661
|
|
637
662
|
nil
|
638
663
|
end
|
@@ -772,6 +797,7 @@ module Riser
|
|
772
797
|
}
|
773
798
|
@dispatcher.accept_return(&NO_CALL)
|
774
799
|
@dispatcher.dispatch(&@dispatch)
|
800
|
+
@dispatcher.dispose(&NO_CALL)
|
775
801
|
end
|
776
802
|
|
777
803
|
nil
|
data/lib/riser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TOKI Yoshinori
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|