serverengine 1.6.3 → 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Changelog +6 -0
- data/lib/serverengine/config_loader.rb +2 -0
- data/lib/serverengine/daemon.rb +2 -2
- data/lib/serverengine/daemon_logger.rb +1 -0
- data/lib/serverengine/signal_thread.rb +1 -1
- data/lib/serverengine/supervisor.rb +1 -1
- data/lib/serverengine/version.rb +1 -1
- data/spec/server_worker_context.rb +71 -72
- data/spec/signal_thread_spec.rb +2 -4
- data/spec/socket_manager_spec.rb +3 -3
- 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: e1905531d61188949bea25a5bd1aa56882b9fd0e
|
4
|
+
data.tar.gz: 225c5c5204167c726710c4790def2f5b7794e179
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2a704566a28f1e90f44934d97e976e82aee1d6867b77bc6497b015c38fef2f538583bb614bdef18de91061b9e1927aa864c7eb50e5e1b0448f8b73eeb4293b6
|
7
|
+
data.tar.gz: c5bab7f53971af7eeaeb4a0a7a58bab5c921d6d39d2c0e00ea154c6cedce39ebe23bf675f8f31896d0dc5fed3b36b218d1e8e079402c97e1d86894dd0448b2a1
|
data/.travis.yml
CHANGED
data/Changelog
CHANGED
data/lib/serverengine/daemon.rb
CHANGED
@@ -31,8 +31,8 @@ module ServerEngine
|
|
31
31
|
@daemonize = @config.fetch(:daemonize, false)
|
32
32
|
|
33
33
|
if @config.fetch(:supervisor, false)
|
34
|
-
@create_server_proc = lambda do |
|
35
|
-
s = Supervisor.new(server_module, worker_module,
|
34
|
+
@create_server_proc = lambda do |_load_config_proc,logger|
|
35
|
+
s = Supervisor.new(server_module, worker_module, _load_config_proc)
|
36
36
|
s.logger = logger
|
37
37
|
s
|
38
38
|
end
|
@@ -32,6 +32,7 @@ module ServerEngine
|
|
32
32
|
def initialize(logdev, config={})
|
33
33
|
@rotate_age = config[:log_rotate_age] || 5
|
34
34
|
@rotate_size = config[:log_rotate_size] || 1048576
|
35
|
+
@file_dev = nil
|
35
36
|
|
36
37
|
if RUBY_VERSION < "2.1.0"
|
37
38
|
# Ruby < 2.1.0 has a problem around log rotation with multiprocess:
|
data/lib/serverengine/version.rb
CHANGED
@@ -29,101 +29,100 @@ def test_state(key)
|
|
29
29
|
return data[key] || 0
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
def wait_for_fork
|
36
|
-
sleep 0.8
|
32
|
+
module TestServer
|
33
|
+
def initialize
|
34
|
+
incr_test_state :server_initialize
|
37
35
|
end
|
38
36
|
|
39
|
-
def
|
40
|
-
|
37
|
+
def before_run
|
38
|
+
incr_test_state :server_before_run
|
41
39
|
end
|
42
40
|
|
43
|
-
def
|
44
|
-
|
41
|
+
def after_run
|
42
|
+
incr_test_state :server_after_run
|
45
43
|
end
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
45
|
+
def after_start
|
46
|
+
incr_test_state :server_after_start
|
47
|
+
end
|
51
48
|
|
52
|
-
|
53
|
-
|
49
|
+
def stop(stop_graceful)
|
50
|
+
incr_test_state :server_stop
|
51
|
+
if stop_graceful
|
52
|
+
incr_test_state :server_stop_graceful
|
53
|
+
else
|
54
|
+
incr_test_state :server_stop_immediate
|
54
55
|
end
|
56
|
+
super
|
57
|
+
end
|
55
58
|
|
56
|
-
|
57
|
-
|
59
|
+
def restart(stop_graceful)
|
60
|
+
incr_test_state :server_restart
|
61
|
+
if stop_graceful
|
62
|
+
incr_test_state :server_restart_graceful
|
63
|
+
else
|
64
|
+
incr_test_state :server_restart_immediate
|
58
65
|
end
|
66
|
+
super
|
67
|
+
end
|
59
68
|
|
60
|
-
|
61
|
-
|
62
|
-
|
69
|
+
def reload
|
70
|
+
incr_test_state :server_reload
|
71
|
+
super
|
72
|
+
end
|
63
73
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
incr_test_state :server_stop_immediate
|
70
|
-
end
|
71
|
-
super
|
72
|
-
end
|
74
|
+
def detach
|
75
|
+
incr_test_state :server_detach
|
76
|
+
super
|
77
|
+
end
|
78
|
+
end
|
73
79
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
incr_test_state :server_restart_immediate
|
80
|
-
end
|
81
|
-
super
|
82
|
-
end
|
80
|
+
module TestWorker
|
81
|
+
def initialize
|
82
|
+
incr_test_state :worker_initialize
|
83
|
+
@stop_flag = BlockingFlag.new
|
84
|
+
end
|
83
85
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
86
|
+
def before_fork
|
87
|
+
incr_test_state :worker_before_fork
|
88
|
+
end
|
88
89
|
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
def run
|
91
|
+
incr_test_state :worker_run
|
92
|
+
5.times do
|
93
|
+
# repeats 5 times because signal handlers
|
94
|
+
# interrupts wait
|
95
|
+
@stop_flag.wait(5.0)
|
92
96
|
end
|
97
|
+
@stop_flag.reset!
|
93
98
|
end
|
94
99
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end
|
100
|
+
def stop
|
101
|
+
incr_test_state :worker_stop
|
102
|
+
@stop_flag.set!
|
103
|
+
end
|
100
104
|
|
101
|
-
|
102
|
-
|
103
|
-
|
105
|
+
def reload
|
106
|
+
incr_test_state :worker_reload
|
107
|
+
end
|
104
108
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
# interrupts wait
|
110
|
-
@stop_flag.wait(5.0)
|
111
|
-
end
|
112
|
-
@stop_flag.reset!
|
113
|
-
end
|
109
|
+
def after_start
|
110
|
+
incr_test_state :worker_after_start
|
111
|
+
end
|
112
|
+
end
|
114
113
|
|
115
|
-
|
116
|
-
|
117
|
-
@stop_flag.set!
|
118
|
-
end
|
114
|
+
shared_context 'test server and worker' do
|
115
|
+
before { reset_test_state }
|
119
116
|
|
120
|
-
|
121
|
-
|
122
|
-
|
117
|
+
def wait_for_fork
|
118
|
+
sleep 0.8
|
119
|
+
end
|
123
120
|
|
124
|
-
|
125
|
-
|
126
|
-
end
|
121
|
+
def wait_for_stop
|
122
|
+
sleep 0.8
|
127
123
|
end
|
128
124
|
|
125
|
+
def wait_for_restart
|
126
|
+
sleep 1.5
|
127
|
+
end
|
129
128
|
end
|
data/spec/signal_thread_spec.rb
CHANGED
@@ -39,7 +39,7 @@ describe ServerEngine::SignalThread do
|
|
39
39
|
it 'signal in handler' do
|
40
40
|
n = 0
|
41
41
|
|
42
|
-
|
42
|
+
SignalThread.new do |st|
|
43
43
|
st.trap('QUIT') do
|
44
44
|
if n < 3
|
45
45
|
Process.kill('QUIT', Process.pid)
|
@@ -55,8 +55,6 @@ describe ServerEngine::SignalThread do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'stop in handler' do
|
58
|
-
n = 0
|
59
|
-
|
60
58
|
t = SignalThread.new do |st|
|
61
59
|
st.trap('QUIT') { st.stop }
|
62
60
|
end
|
@@ -70,7 +68,7 @@ describe ServerEngine::SignalThread do
|
|
70
68
|
it 'should not deadlock' do
|
71
69
|
n = 0
|
72
70
|
|
73
|
-
|
71
|
+
SignalThread.new do |st|
|
74
72
|
st.trap('CONT') { n += 1 }
|
75
73
|
end
|
76
74
|
|
data/spec/socket_manager_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe ServerEngine::SocketManager do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
after(:each) do
|
10
|
-
File.unlink(server_path) if File.
|
10
|
+
File.unlink(server_path) if File.exist?(server_path)
|
11
11
|
end
|
12
12
|
|
13
13
|
if ServerEngine.windows?
|
@@ -37,7 +37,7 @@ describe ServerEngine::SocketManager do
|
|
37
37
|
incr_test_state(:is_tcp_server) if tcp.is_a?(TCPServer)
|
38
38
|
incr_test_state(:is_udp_socket) if udp.is_a?(UDPSocket)
|
39
39
|
|
40
|
-
data,
|
40
|
+
data, _from = udp.recvfrom(10)
|
41
41
|
incr_test_state(:udp_data_sent) if data == "ok"
|
42
42
|
|
43
43
|
s = tcp.accept
|
@@ -89,7 +89,7 @@ describe ServerEngine::SocketManager do
|
|
89
89
|
incr_test_state(:is_tcp_server) if tcp.is_a?(TCPServer)
|
90
90
|
incr_test_state(:is_udp_socket) if udp.is_a?(UDPSocket)
|
91
91
|
|
92
|
-
data,
|
92
|
+
data, _from = udp.recvfrom(10)
|
93
93
|
incr_test_state(:udp_data_sent) if data == "ok"
|
94
94
|
|
95
95
|
s = tcp.accept
|
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: 1.6.
|
4
|
+
version: 1.6.4
|
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-
|
11
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sigdump
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.4.5
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: ServerEngine - multiprocess server framework
|