serverengine 2.0.5-x64-mingw32 → 2.1.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/Changelog +12 -0
- data/README.md +3 -1
- data/lib/serverengine/process_manager.rb +2 -0
- data/lib/serverengine/server.rb +7 -2
- data/lib/serverengine/socket_manager.rb +23 -4
- data/lib/serverengine/socket_manager_unix.rb +14 -2
- data/lib/serverengine/supervisor.rb +6 -2
- data/lib/serverengine/version.rb +1 -1
- data/lib/serverengine/worker.rb +5 -2
- data/serverengine.gemspec +0 -1
- data/spec/daemon_spec.rb +4 -0
- data/spec/server_worker_context.rb +5 -0
- 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: b19cbdc7a46aab03ef5d5a68591f9766424c1d2a
|
4
|
+
data.tar.gz: fcad502cbe6d11ef8f1abddeb268de34c170cae1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e9b9f8fda192d2b7d7d7a9b4839b1ff396fcfa9af28ca5578ebd113f7d29bf84608161587c82a32fef4182778cc188343140cc9f4edde97722f2d79a5ed586a
|
7
|
+
data.tar.gz: 5f1731e924aa75071775b398b4fb49f54e6b12d41542467b5224eb4a36d273d1d95a54a4eed49d645d8f57d13eb4ec66730cd0891f3edb88f5df2f269b650d69
|
data/.travis.yml
CHANGED
data/Changelog
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
2018-11-14 version 2.1.0:
|
2
|
+
|
3
|
+
* Improve socket manager security
|
4
|
+
|
5
|
+
2018-07-09 version 2.0.7:
|
6
|
+
|
7
|
+
* Add disable_sigdump option
|
8
|
+
|
9
|
+
2018-02-09 version 2.0.6:
|
10
|
+
|
11
|
+
* Avoid thread error log in ruby 2.5
|
12
|
+
|
1
13
|
2017-03-01 version 2.0.5:
|
2
14
|
|
3
15
|
* Support SERVERENGINE_SOCKETMANAGER_SOCK_DIR environment variable to change
|
data/README.md
CHANGED
@@ -319,7 +319,8 @@ Send `USR2` signal to reload configuration file.
|
|
319
319
|
- **HUP:** immediate restart (available only when `worker_type` is "process")
|
320
320
|
- **USR2:** reload config file and reopen log file
|
321
321
|
- **INT:** detach process for live restarting (available only when `supervisor` and `enable_detach` parameters are true. otherwise graceful shutdown)
|
322
|
-
- **CONT:** dump stacktrace and memory information to /tmp/sigdump-<pid>.log file
|
322
|
+
- **CONT:** dump stacktrace and memory information to /tmp/sigdump-<pid>.log file. This can be
|
323
|
+
disabled by including `disable_sigdump: true` in the configuration.
|
323
324
|
|
324
325
|
Immediate shutdown and restart send SIGQUIT signal to worker processes which kills the processes.
|
325
326
|
Graceful shutdown and restart call `Worker#stop` method and wait for completion of `Worker#run` method.
|
@@ -463,6 +464,7 @@ Available methods are different depending on `worker_type`. ServerEngine support
|
|
463
464
|
- **daemonize** enables daemonize (default: false)
|
464
465
|
- **pid_path** sets the path to pid file (default: don't create pid file)
|
465
466
|
- **supervisor** enables supervisor if it's true (default: false)
|
467
|
+
- **disable_sigdump** disables the handling of the `SIGCONT` signal and dumping of the thread (default: false)
|
466
468
|
- **daemon_process_name** changes process name ($0) of server or supervisor process
|
467
469
|
- **chuser** changes execution user
|
468
470
|
- **chgroup** changes execution group
|
@@ -16,6 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
require 'fcntl'
|
19
|
+
require 'serverengine/socket_manager'
|
19
20
|
|
20
21
|
module ServerEngine
|
21
22
|
|
@@ -185,6 +186,7 @@ module ServerEngine
|
|
185
186
|
@command_sender_pipe.binmode
|
186
187
|
options[:in] = inpipe
|
187
188
|
end
|
189
|
+
env['SERVERENGINE_SOCKETMANAGER_INTERNAL_TOKEN'] = SocketManager::INTERNAL_TOKEN
|
188
190
|
pid = Process.spawn(env, *args, options)
|
189
191
|
if @command_sender == "pipe"
|
190
192
|
inpipe.close
|
data/lib/serverengine/server.rb
CHANGED
@@ -70,6 +70,11 @@ module ServerEngine
|
|
70
70
|
nil
|
71
71
|
end
|
72
72
|
|
73
|
+
def dump
|
74
|
+
Sigdump.dump unless config[:disable_sigdump]
|
75
|
+
nil
|
76
|
+
end
|
77
|
+
|
73
78
|
def install_signal_handlers
|
74
79
|
s = self
|
75
80
|
if @command_pipe
|
@@ -89,7 +94,7 @@ module ServerEngine
|
|
89
94
|
when "DETACH"
|
90
95
|
s.detach(true)
|
91
96
|
when "DUMP"
|
92
|
-
|
97
|
+
s.dump
|
93
98
|
end
|
94
99
|
end
|
95
100
|
end
|
@@ -104,7 +109,7 @@ module ServerEngine
|
|
104
109
|
st.trap(@config[:signal_graceful_restart] || Signals::GRACEFUL_RESTART) { s.restart(true) }
|
105
110
|
st.trap(@config[:signal_immediate_restart] || Signals::IMMEDIATE_RESTART) { s.restart(false) }
|
106
111
|
st.trap(@config[:signal_reload] || Signals::RELOAD) { s.reload }
|
107
|
-
st.trap(@config[:signal_dump] || Signals::DUMP) {
|
112
|
+
st.trap(@config[:signal_dump] || Signals::DUMP) { s.dump }
|
108
113
|
end
|
109
114
|
end
|
110
115
|
end
|
@@ -18,9 +18,18 @@
|
|
18
18
|
require 'socket'
|
19
19
|
require 'ipaddr'
|
20
20
|
require 'time'
|
21
|
+
require 'securerandom'
|
22
|
+
require 'json'
|
23
|
+
require 'base64'
|
21
24
|
|
22
25
|
module ServerEngine
|
23
26
|
module SocketManager
|
27
|
+
# This token is used for communication between peers. If token is mismatched, messages will be discarded
|
28
|
+
INTERNAL_TOKEN = if ENV.has_key?('SERVERENGINE_SOCKETMANAGER_INTERNAL_TOKEN')
|
29
|
+
ENV['SERVERENGINE_SOCKETMANAGER_INTERNAL_TOKEN']
|
30
|
+
else
|
31
|
+
SecureRandom.hex
|
32
|
+
end
|
24
33
|
|
25
34
|
class Client
|
26
35
|
def initialize(path)
|
@@ -138,7 +147,10 @@ module ServerEngine
|
|
138
147
|
|
139
148
|
def process_peer(peer)
|
140
149
|
while true
|
141
|
-
|
150
|
+
res = SocketManager.recv_peer(peer)
|
151
|
+
return if res.nil?
|
152
|
+
|
153
|
+
pid, method, bind, port = *res
|
142
154
|
begin
|
143
155
|
send_socket(peer, pid, method, bind, port)
|
144
156
|
rescue => e
|
@@ -151,15 +163,22 @@ module ServerEngine
|
|
151
163
|
end
|
152
164
|
|
153
165
|
def self.send_peer(peer, obj)
|
154
|
-
data = Marshal.dump(obj)
|
166
|
+
data = [SocketManager::INTERNAL_TOKEN, Base64.strict_encode64(Marshal.dump(obj))]
|
167
|
+
data = JSON.generate(data)
|
155
168
|
peer.write [data.bytesize].pack('N')
|
156
169
|
peer.write data
|
157
170
|
end
|
158
171
|
|
159
172
|
def self.recv_peer(peer)
|
160
|
-
|
173
|
+
res = peer.read(4)
|
174
|
+
return nil if res.nil?
|
175
|
+
|
176
|
+
len = res.unpack('N').first
|
161
177
|
data = peer.read(len)
|
162
|
-
|
178
|
+
data = JSON.parse(data)
|
179
|
+
return nil if SocketManager::INTERNAL_TOKEN != data.first
|
180
|
+
|
181
|
+
Marshal.load(Base64.strict_decode64(data.last))
|
163
182
|
end
|
164
183
|
|
165
184
|
if ServerEngine.windows?
|
@@ -70,7 +70,12 @@ module ServerEngine
|
|
70
70
|
# when client changed working directory
|
71
71
|
path = File.expand_path(path)
|
72
72
|
|
73
|
-
|
73
|
+
begin
|
74
|
+
old_umask = File.umask(0077) # Protect unix socket from other users
|
75
|
+
@server = UNIXServer.new(path)
|
76
|
+
ensure
|
77
|
+
File.umask(old_umask)
|
78
|
+
end
|
74
79
|
|
75
80
|
@thread = Thread.new do
|
76
81
|
begin
|
@@ -96,7 +101,14 @@ module ServerEngine
|
|
96
101
|
end
|
97
102
|
|
98
103
|
def send_socket(peer, pid, method, bind, port)
|
99
|
-
sock =
|
104
|
+
sock = case method
|
105
|
+
when :listen_tcp
|
106
|
+
listen_tcp(bind, port)
|
107
|
+
when :listen_udp
|
108
|
+
listen_udp(bind, port)
|
109
|
+
else
|
110
|
+
raise ArgumentError, "Unknown method: #{method.inspect}"
|
111
|
+
end
|
100
112
|
|
101
113
|
SocketManager.send_peer(peer, nil)
|
102
114
|
|
@@ -148,6 +148,10 @@ module ServerEngine
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
+
def dump
|
152
|
+
_dump
|
153
|
+
end
|
154
|
+
|
151
155
|
def install_signal_handlers
|
152
156
|
s = self
|
153
157
|
if @command_pipe
|
@@ -167,7 +171,7 @@ module ServerEngine
|
|
167
171
|
when "DETACH"
|
168
172
|
s.detach(true)
|
169
173
|
when "DUMP"
|
170
|
-
|
174
|
+
s.dump
|
171
175
|
end
|
172
176
|
end
|
173
177
|
end
|
@@ -179,7 +183,7 @@ module ServerEngine
|
|
179
183
|
st.trap(Signals::IMMEDIATE_RESTART) { s.restart(false) }
|
180
184
|
st.trap(Signals::RELOAD) { s.reload }
|
181
185
|
st.trap(Signals::DETACH) { s.detach(true) }
|
182
|
-
st.trap(Signals::DUMP) {
|
186
|
+
st.trap(Signals::DUMP) { s.dump }
|
183
187
|
end
|
184
188
|
end
|
185
189
|
end
|
data/lib/serverengine/version.rb
CHANGED
data/lib/serverengine/worker.rb
CHANGED
@@ -54,6 +54,10 @@ module ServerEngine
|
|
54
54
|
def after_start
|
55
55
|
end
|
56
56
|
|
57
|
+
def dump
|
58
|
+
Sigdump.dump unless config[:disable_sigdump]
|
59
|
+
end
|
60
|
+
|
57
61
|
def install_signal_handlers
|
58
62
|
w = self
|
59
63
|
SignalThread.new do |st|
|
@@ -69,7 +73,7 @@ module ServerEngine
|
|
69
73
|
}
|
70
74
|
st.trap(Signals::DETACH) { w.stop }
|
71
75
|
|
72
|
-
st.trap(Signals::DUMP) {
|
76
|
+
st.trap(Signals::DUMP) { w.dump }
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
@@ -77,5 +81,4 @@ module ServerEngine
|
|
77
81
|
run
|
78
82
|
end
|
79
83
|
end
|
80
|
-
|
81
84
|
end
|
data/serverengine.gemspec
CHANGED
@@ -15,7 +15,6 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
16
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
17
|
gem.require_paths = ["lib"]
|
18
|
-
gem.has_rdoc = false
|
19
18
|
|
20
19
|
gem.required_ruby_version = ">= 2.1.0"
|
21
20
|
|
data/spec/daemon_spec.rb
CHANGED
@@ -44,6 +44,10 @@ describe ServerEngine::Daemon do
|
|
44
44
|
wait_for_stop
|
45
45
|
test_state(:server_restart_immediate).should == 1
|
46
46
|
|
47
|
+
dm.dump
|
48
|
+
wait_for_stop
|
49
|
+
test_state(:server_dump).should == 1
|
50
|
+
|
47
51
|
dm.stop(false)
|
48
52
|
wait_for_stop
|
49
53
|
test_state(:server_stop_immediate).should == 1
|
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.1.0
|
5
5
|
platform: x64-mingw32
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sigdump
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.6.
|
171
|
+
rubygems_version: 2.6.14.1
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: ServerEngine - multiprocess server framework
|