bayserver-core 2.3.2 → 3.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/baykit/bayserver/agent/accept_handler.rb +0 -26
- data/lib/baykit/bayserver/agent/channel_listener.rb +6 -6
- data/lib/baykit/bayserver/agent/command_receiver.rb +97 -38
- data/lib/baykit/bayserver/agent/grand_agent.rb +444 -134
- data/lib/baykit/bayserver/agent/letter.rb +30 -0
- data/lib/baykit/bayserver/agent/lifecycle_listener.rb +9 -7
- data/lib/baykit/bayserver/agent/monitor/grand_agent_monitor.rb +298 -0
- data/lib/baykit/bayserver/agent/multiplexer/job_multiplexer.rb +257 -0
- data/lib/baykit/bayserver/agent/multiplexer/job_multiplexer_base.rb +52 -0
- data/lib/baykit/bayserver/agent/multiplexer/multiplexer_base.rb +150 -0
- data/lib/baykit/bayserver/agent/multiplexer/plain_transporter.rb +129 -0
- data/lib/baykit/bayserver/agent/multiplexer/rudder_state.rb +81 -0
- data/lib/baykit/bayserver/agent/multiplexer/secure_transporter.rb +50 -0
- data/lib/baykit/bayserver/agent/multiplexer/spider_multiplexer.rb +561 -0
- data/lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb +311 -0
- data/lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb +194 -0
- data/lib/baykit/bayserver/agent/multiplexer/transporter.rb +61 -0
- data/lib/baykit/bayserver/agent/multiplexer/write_unit.rb +30 -0
- data/lib/baykit/bayserver/agent/non_blocking_handler.rb +0 -319
- data/lib/baykit/bayserver/agent/signal/signal_agent.rb +2 -1
- data/lib/baykit/bayserver/agent/timer_handler.rb +1 -1
- data/lib/baykit/bayserver/agent/transporter/data_listener.rb +7 -7
- data/lib/baykit/bayserver/agent/transporter/package.rb +0 -3
- data/lib/baykit/bayserver/agent/transporter/transporter.rb +5 -139
- data/lib/baykit/bayserver/bay_log.rb +1 -0
- data/lib/baykit/bayserver/bayserver.rb +32 -28
- data/lib/baykit/bayserver/{util → common}/groups.rb +1 -1
- data/lib/baykit/bayserver/common/inbound_handler.rb +12 -0
- data/lib/baykit/bayserver/{docker/base → common}/inbound_ship.rb +94 -19
- data/lib/baykit/bayserver/{docker/base → common}/inbound_ship_store.rb +7 -9
- data/lib/baykit/bayserver/common/multiplexer.rb +98 -0
- data/lib/baykit/bayserver/common/postpone.rb +15 -0
- data/lib/baykit/bayserver/common/read_only_ship.rb +42 -0
- data/lib/baykit/bayserver/common/recipient.rb +24 -0
- data/lib/baykit/bayserver/common/vehicle.rb +24 -0
- data/lib/baykit/bayserver/common/vehicle_runner.rb +127 -0
- data/lib/baykit/bayserver/{docker/warp → common}/warp_data.rb +18 -10
- data/lib/baykit/bayserver/common/warp_handler.rb +27 -0
- data/lib/baykit/bayserver/{docker/warp → common}/warp_ship.rb +107 -27
- data/lib/baykit/bayserver/{docker/warp → common}/warp_ship_store.rb +3 -8
- data/lib/baykit/bayserver/docker/base/inbound_data_listener.rb +2 -2
- data/lib/baykit/bayserver/docker/base/port_base.rb +59 -27
- data/lib/baykit/bayserver/docker/{warp/warp_docker.rb → base/warp_base.rb} +43 -50
- data/lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb +118 -31
- data/lib/baykit/bayserver/docker/built_in/built_in_log_docker.rb +60 -63
- data/lib/baykit/bayserver/docker/built_in/built_in_permission_docker.rb +11 -10
- data/lib/baykit/bayserver/docker/built_in/built_in_secure_docker.rb +13 -4
- data/lib/baykit/bayserver/docker/city.rb +27 -13
- data/lib/baykit/bayserver/docker/club.rb +8 -8
- data/lib/baykit/bayserver/docker/docker.rb +9 -1
- data/lib/baykit/bayserver/docker/harbor.rb +184 -22
- data/lib/baykit/bayserver/docker/permission.rb +7 -6
- data/lib/baykit/bayserver/docker/port.rb +39 -11
- data/lib/baykit/bayserver/docker/secure.rb +11 -9
- data/lib/baykit/bayserver/docker/send_file/file_content_handler.rb +99 -4
- data/lib/baykit/bayserver/docker/send_file/send_file_docker.rb +6 -2
- data/lib/baykit/bayserver/docker/send_file/send_file_ship.rb +92 -0
- data/lib/baykit/bayserver/docker/town.rb +31 -15
- data/lib/baykit/bayserver/docker/trouble.rb +17 -5
- data/lib/baykit/bayserver/docker/warp.rb +34 -0
- data/lib/baykit/bayserver/mem_usage.rb +9 -9
- data/lib/baykit/bayserver/protocol/command_packer.rb +1 -8
- data/lib/baykit/bayserver/protocol/packet_packer.rb +7 -11
- data/lib/baykit/bayserver/protocol/packet_store.rb +4 -4
- data/lib/baykit/bayserver/protocol/protocol_handler.rb +26 -8
- data/lib/baykit/bayserver/protocol/protocol_handler_store.rb +5 -5
- data/lib/baykit/bayserver/rudders/io_rudder.rb +62 -0
- data/lib/baykit/bayserver/rudders/rudder.rb +29 -0
- data/lib/baykit/bayserver/{watercraft → ships}/ship.rb +65 -41
- data/lib/baykit/bayserver/taxi/taxi.rb +15 -10
- data/lib/baykit/bayserver/taxi/taxi_runner.rb +9 -94
- data/lib/baykit/bayserver/tours/read_file_taxi.rb +2 -2
- data/lib/baykit/bayserver/tours/req_content_handler.rb +16 -13
- data/lib/baykit/bayserver/tours/tour.rb +2 -2
- data/lib/baykit/bayserver/tours/tour_handler.rb +36 -0
- data/lib/baykit/bayserver/tours/tour_req.rb +14 -24
- data/lib/baykit/bayserver/tours/tour_res.rb +5 -89
- data/lib/baykit/bayserver/tours/tour_store.rb +5 -5
- data/lib/baykit/bayserver/train/train_runner.rb +17 -13
- data/lib/baykit/bayserver/util/data_consume_listener.rb +1 -1
- data/lib/baykit/bayserver/util/executor_service.rb +11 -7
- data/lib/baykit/bayserver/util/ip_matcher.rb +9 -39
- data/lib/baykit/bayserver/util/locale.rb +1 -1
- data/lib/baykit/bayserver/util/selector.rb +24 -5
- data/lib/baykit/bayserver/util/sys_util.rb +6 -6
- data/lib/baykit/bayserver/version.rb +1 -1
- metadata +37 -18
- data/lib/baykit/bayserver/agent/grand_agent_monitor.rb +0 -231
- data/lib/baykit/bayserver/agent/transporter/plain_transporter.rb +0 -55
- data/lib/baykit/bayserver/agent/transporter/secure_transporter.rb +0 -81
- data/lib/baykit/bayserver/docker/base/inbound_handler.rb +0 -42
- data/lib/baykit/bayserver/docker/warp/package.rb +0 -4
- data/lib/baykit/bayserver/docker/warp/warp_data_listener.rb +0 -112
- data/lib/baykit/bayserver/docker/warp/warp_handler.rb +0 -38
- /data/lib/baykit/bayserver/{util → common}/cities.rb +0 -0
@@ -3,14 +3,13 @@ module Baykit
|
|
3
3
|
module Util
|
4
4
|
class IpMatcher
|
5
5
|
attr :match_all
|
6
|
-
attr :
|
7
|
-
attr :mask_addr
|
6
|
+
attr :cidr_ip
|
8
7
|
|
9
8
|
def initialize(ip_desc)
|
10
9
|
@match_all = (ip_desc == "*")
|
11
10
|
|
12
11
|
if !@match_all
|
13
|
-
|
12
|
+
parse_cidr(ip_desc)
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
@@ -19,48 +18,19 @@ module Baykit
|
|
19
18
|
if @match_all
|
20
19
|
return true
|
21
20
|
else
|
22
|
-
|
23
|
-
# IPv4 and IPv6 don't match each other
|
24
|
-
return false
|
25
|
-
end
|
26
|
-
|
27
|
-
if ip & @mask_addr != @net_addr
|
28
|
-
return false
|
29
|
-
end
|
30
|
-
|
31
|
-
return true
|
21
|
+
return @cidr_ip.include?(ip)
|
32
22
|
end
|
33
23
|
end
|
34
24
|
|
35
|
-
def get_ip_addr(ip)
|
36
|
-
return IPAddr.new(ip)
|
37
|
-
end
|
38
|
-
|
39
25
|
private
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
ip = items[0]
|
47
|
-
if items.length == 1
|
48
|
-
mask = "255.255.255.255"
|
49
|
-
else
|
50
|
-
mask = items[1]
|
51
|
-
end
|
52
|
-
|
53
|
-
ip_addr = get_ip_addr(ip)
|
54
|
-
@mask_addr = get_ip_addr(mask)
|
55
|
-
|
56
|
-
if ip_addr.ipv4? != @mask_addr.ipv4?
|
57
|
-
raise RuntimeError.new(BayMessage.get(:CFG_IPV4_AND_IPV6_ARE_MIXED, ip_desc))
|
26
|
+
def parse_cidr(cidr)
|
27
|
+
begin
|
28
|
+
@cidr_ip = IPAddr.new(cidr)
|
29
|
+
rescue => e
|
30
|
+
BayLog.error_e(e)
|
31
|
+
raise RuntimeError.new(BayMessage.get(:CFG_INVALID_IP_DESC, cidr))
|
58
32
|
end
|
59
|
-
|
60
|
-
@net_addr = ip_addr & @mask_addr
|
61
33
|
end
|
62
|
-
|
63
|
-
|
64
34
|
end
|
65
35
|
end
|
66
36
|
end
|
@@ -18,6 +18,10 @@ module Baykit
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def register(ch, op)
|
21
|
+
#BayLog.debug("register io=%s", ch)
|
22
|
+
if not ((ch.kind_of? IO) || (ch.kind_of? OpenSSL::SSL::SSLSocket))
|
23
|
+
raise ArgumentError
|
24
|
+
end
|
21
25
|
if op & OP_READ != 0
|
22
26
|
register_read(ch, @channels)
|
23
27
|
end
|
@@ -27,11 +31,18 @@ module Baykit
|
|
27
31
|
end
|
28
32
|
|
29
33
|
def unregister(ch)
|
34
|
+
#BayLog.debug("unregister io=%s", ch)
|
35
|
+
if not ((ch.kind_of? IO) || (ch.kind_of? OpenSSL::SSL::SSLSocket))
|
36
|
+
raise ArgumentError
|
37
|
+
end
|
30
38
|
unregister_read(ch, @channels)
|
31
39
|
unregister_write(ch, @channels)
|
32
40
|
end
|
33
41
|
|
34
42
|
def modify(ch, op)
|
43
|
+
if not ((ch.kind_of? IO) || (ch.kind_of? OpenSSL::SSL::SSLSocket))
|
44
|
+
raise ArgumentError
|
45
|
+
end
|
35
46
|
if op & OP_READ != 0
|
36
47
|
register_read(ch, @channels)
|
37
48
|
else
|
@@ -46,10 +57,16 @@ module Baykit
|
|
46
57
|
end
|
47
58
|
|
48
59
|
def get_op(ch)
|
60
|
+
if not ((ch.kind_of? IO) || (ch.kind_of? OpenSSL::SSL::SSLSocket))
|
61
|
+
raise ArgumentError
|
62
|
+
end
|
49
63
|
return @channels[ch]
|
50
64
|
end
|
51
65
|
|
52
|
-
def select(
|
66
|
+
def select(timeout_sec = nil)
|
67
|
+
if timeout_sec == nil
|
68
|
+
timeout_sec = 0
|
69
|
+
end
|
53
70
|
except_list = []
|
54
71
|
|
55
72
|
read_list = []
|
@@ -64,16 +81,18 @@ module Baykit
|
|
64
81
|
end
|
65
82
|
end
|
66
83
|
end
|
67
|
-
|
84
|
+
#BayLog.debug("Select read_list=%s", read_list)
|
85
|
+
#BayLog.debug("Select write_list=%s", write_list)
|
86
|
+
selected_read_list, selected_write_list = Kernel.select(read_list, write_list, except_list, timeout_sec)
|
68
87
|
|
69
88
|
result = {}
|
70
|
-
if selected_read_list
|
89
|
+
if selected_read_list != nil
|
71
90
|
selected_read_list.each do |ch|
|
72
91
|
register_read(ch, result)
|
73
92
|
end
|
74
93
|
end
|
75
94
|
|
76
|
-
if selected_write_list
|
95
|
+
if selected_write_list != nil
|
77
96
|
selected_write_list.each do |ch|
|
78
97
|
register_write(ch, result)
|
79
98
|
end
|
@@ -82,7 +101,7 @@ module Baykit
|
|
82
101
|
return result
|
83
102
|
end
|
84
103
|
|
85
|
-
def count
|
104
|
+
def count
|
86
105
|
@lock.synchronize do
|
87
106
|
return @channels.length
|
88
107
|
end
|
@@ -30,7 +30,7 @@ module Baykit
|
|
30
30
|
Process.waitpid(pid)
|
31
31
|
return true
|
32
32
|
rescue NotImplementedError => e
|
33
|
-
if BayLog.debug_mode
|
33
|
+
if BayLog.debug_mode
|
34
34
|
BayLog.warn("fork() failed: %s ", e)
|
35
35
|
#BayLog.warn_e(e)
|
36
36
|
end
|
@@ -45,7 +45,7 @@ module Baykit
|
|
45
45
|
n = select([f], [], [], 10)
|
46
46
|
return true
|
47
47
|
rescue IOError => e
|
48
|
-
if BayLog.debug_mode
|
48
|
+
if BayLog.debug_mode
|
49
49
|
BayLog.warn("select() failed: %s", e)
|
50
50
|
#BayLog.warn_e(e)
|
51
51
|
end
|
@@ -61,7 +61,7 @@ module Baykit
|
|
61
61
|
f.read_nonblock(1)
|
62
62
|
return true
|
63
63
|
rescue SystemCallError => e
|
64
|
-
if BayLog.debug_mode
|
64
|
+
if BayLog.debug_mode
|
65
65
|
BayLog.warn("read_nonblock() failed: %s", e)
|
66
66
|
#BayLog.warn_e(e)
|
67
67
|
end
|
@@ -77,7 +77,7 @@ module Baykit
|
|
77
77
|
f.write_nonblock(1)
|
78
78
|
return true
|
79
79
|
rescue SystemCallError => e
|
80
|
-
if BayLog.debug_mode
|
80
|
+
if BayLog.debug_mode
|
81
81
|
BayLog.warn("write_nonblock() failed: %s", e)
|
82
82
|
#BayLog.warn_e(e)
|
83
83
|
end
|
@@ -94,7 +94,7 @@ module Baykit
|
|
94
94
|
n = select([r], [w], [], 10)
|
95
95
|
return true
|
96
96
|
rescue IOError => e
|
97
|
-
if BayLog.debug_mode
|
97
|
+
if BayLog.debug_mode
|
98
98
|
BayLog.warn("select() failed: %s", e)
|
99
99
|
#BayLog.warn_e(e)
|
100
100
|
end
|
@@ -111,7 +111,7 @@ module Baykit
|
|
111
111
|
r.read_nonblock(1)
|
112
112
|
return true
|
113
113
|
rescue SystemCallError => e
|
114
|
-
if BayLog.debug_mode
|
114
|
+
if BayLog.debug_mode
|
115
115
|
BayLog.warn("read_nonblock() failed: %s", e)
|
116
116
|
#BayLog.warn_e(e)
|
117
117
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bayserver-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michisuke-P
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: BayServer is one of the high-speed web servers. It operates as a single-threaded,
|
14
14
|
asynchronous server, which makes it exceptionally fast. It also supports multi-core
|
@@ -24,8 +24,20 @@ files:
|
|
24
24
|
- lib/baykit/bayserver/agent/channel_listener.rb
|
25
25
|
- lib/baykit/bayserver/agent/command_receiver.rb
|
26
26
|
- lib/baykit/bayserver/agent/grand_agent.rb
|
27
|
-
- lib/baykit/bayserver/agent/
|
27
|
+
- lib/baykit/bayserver/agent/letter.rb
|
28
28
|
- lib/baykit/bayserver/agent/lifecycle_listener.rb
|
29
|
+
- lib/baykit/bayserver/agent/monitor/grand_agent_monitor.rb
|
30
|
+
- lib/baykit/bayserver/agent/multiplexer/job_multiplexer.rb
|
31
|
+
- lib/baykit/bayserver/agent/multiplexer/job_multiplexer_base.rb
|
32
|
+
- lib/baykit/bayserver/agent/multiplexer/multiplexer_base.rb
|
33
|
+
- lib/baykit/bayserver/agent/multiplexer/plain_transporter.rb
|
34
|
+
- lib/baykit/bayserver/agent/multiplexer/rudder_state.rb
|
35
|
+
- lib/baykit/bayserver/agent/multiplexer/secure_transporter.rb
|
36
|
+
- lib/baykit/bayserver/agent/multiplexer/spider_multiplexer.rb
|
37
|
+
- lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb
|
38
|
+
- lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb
|
39
|
+
- lib/baykit/bayserver/agent/multiplexer/transporter.rb
|
40
|
+
- lib/baykit/bayserver/agent/multiplexer/write_unit.rb
|
29
41
|
- lib/baykit/bayserver/agent/next_socket_action.rb
|
30
42
|
- lib/baykit/bayserver/agent/non_blocking_handler.rb
|
31
43
|
- lib/baykit/bayserver/agent/package.rb
|
@@ -36,8 +48,6 @@ files:
|
|
36
48
|
- lib/baykit/bayserver/agent/timer_handler.rb
|
37
49
|
- lib/baykit/bayserver/agent/transporter/data_listener.rb
|
38
50
|
- lib/baykit/bayserver/agent/transporter/package.rb
|
39
|
-
- lib/baykit/bayserver/agent/transporter/plain_transporter.rb
|
40
|
-
- lib/baykit/bayserver/agent/transporter/secure_transporter.rb
|
41
51
|
- lib/baykit/bayserver/agent/transporter/spin_read_transporter.rb
|
42
52
|
- lib/baykit/bayserver/agent/transporter/spin_write_transporter.rb
|
43
53
|
- lib/baykit/bayserver/agent/transporter/transporter.rb
|
@@ -54,16 +64,29 @@ files:
|
|
54
64
|
- lib/baykit/bayserver/bcf/bcf_parser.rb
|
55
65
|
- lib/baykit/bayserver/bcf/package.rb
|
56
66
|
- lib/baykit/bayserver/bcf/parse_exception.rb
|
67
|
+
- lib/baykit/bayserver/common/cities.rb
|
68
|
+
- lib/baykit/bayserver/common/groups.rb
|
69
|
+
- lib/baykit/bayserver/common/inbound_handler.rb
|
70
|
+
- lib/baykit/bayserver/common/inbound_ship.rb
|
71
|
+
- lib/baykit/bayserver/common/inbound_ship_store.rb
|
72
|
+
- lib/baykit/bayserver/common/multiplexer.rb
|
73
|
+
- lib/baykit/bayserver/common/postpone.rb
|
74
|
+
- lib/baykit/bayserver/common/read_only_ship.rb
|
75
|
+
- lib/baykit/bayserver/common/recipient.rb
|
76
|
+
- lib/baykit/bayserver/common/vehicle.rb
|
77
|
+
- lib/baykit/bayserver/common/vehicle_runner.rb
|
78
|
+
- lib/baykit/bayserver/common/warp_data.rb
|
79
|
+
- lib/baykit/bayserver/common/warp_handler.rb
|
80
|
+
- lib/baykit/bayserver/common/warp_ship.rb
|
81
|
+
- lib/baykit/bayserver/common/warp_ship_store.rb
|
57
82
|
- lib/baykit/bayserver/config_exception.rb
|
58
83
|
- lib/baykit/bayserver/constants.rb
|
59
84
|
- lib/baykit/bayserver/docker/base/club_base.rb
|
60
85
|
- lib/baykit/bayserver/docker/base/docker_base.rb
|
61
86
|
- lib/baykit/bayserver/docker/base/inbound_data_listener.rb
|
62
|
-
- lib/baykit/bayserver/docker/base/inbound_handler.rb
|
63
|
-
- lib/baykit/bayserver/docker/base/inbound_ship.rb
|
64
|
-
- lib/baykit/bayserver/docker/base/inbound_ship_store.rb
|
65
87
|
- lib/baykit/bayserver/docker/base/port_base.rb
|
66
88
|
- lib/baykit/bayserver/docker/base/reroute_base.rb
|
89
|
+
- lib/baykit/bayserver/docker/base/warp_base.rb
|
67
90
|
- lib/baykit/bayserver/docker/built_in/built_in_city_docker.rb
|
68
91
|
- lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb
|
69
92
|
- lib/baykit/bayserver/docker/built_in/built_in_log_docker.rb
|
@@ -89,15 +112,10 @@ files:
|
|
89
112
|
- lib/baykit/bayserver/docker/send_file/directory_train.rb
|
90
113
|
- lib/baykit/bayserver/docker/send_file/file_content_handler.rb
|
91
114
|
- lib/baykit/bayserver/docker/send_file/send_file_docker.rb
|
115
|
+
- lib/baykit/bayserver/docker/send_file/send_file_ship.rb
|
92
116
|
- lib/baykit/bayserver/docker/town.rb
|
93
117
|
- lib/baykit/bayserver/docker/trouble.rb
|
94
|
-
- lib/baykit/bayserver/docker/warp
|
95
|
-
- lib/baykit/bayserver/docker/warp/warp_data.rb
|
96
|
-
- lib/baykit/bayserver/docker/warp/warp_data_listener.rb
|
97
|
-
- lib/baykit/bayserver/docker/warp/warp_docker.rb
|
98
|
-
- lib/baykit/bayserver/docker/warp/warp_handler.rb
|
99
|
-
- lib/baykit/bayserver/docker/warp/warp_ship.rb
|
100
|
-
- lib/baykit/bayserver/docker/warp/warp_ship_store.rb
|
118
|
+
- lib/baykit/bayserver/docker/warp.rb
|
101
119
|
- lib/baykit/bayserver/http_exception.rb
|
102
120
|
- lib/baykit/bayserver/mem_usage.rb
|
103
121
|
- lib/baykit/bayserver/protocol/command.rb
|
@@ -115,6 +133,9 @@ files:
|
|
115
133
|
- lib/baykit/bayserver/protocol/protocol_handler.rb
|
116
134
|
- lib/baykit/bayserver/protocol/protocol_handler_factory.rb
|
117
135
|
- lib/baykit/bayserver/protocol/protocol_handler_store.rb
|
136
|
+
- lib/baykit/bayserver/rudders/io_rudder.rb
|
137
|
+
- lib/baykit/bayserver/rudders/rudder.rb
|
138
|
+
- lib/baykit/bayserver/ships/ship.rb
|
118
139
|
- lib/baykit/bayserver/sink.rb
|
119
140
|
- lib/baykit/bayserver/taxi/taxi.rb
|
120
141
|
- lib/baykit/bayserver/taxi/taxi_runner.rb
|
@@ -125,6 +146,7 @@ files:
|
|
125
146
|
- lib/baykit/bayserver/tours/send_file_train.rb
|
126
147
|
- lib/baykit/bayserver/tours/send_file_yacht.rb
|
127
148
|
- lib/baykit/bayserver/tours/tour.rb
|
149
|
+
- lib/baykit/bayserver/tours/tour_handler.rb
|
128
150
|
- lib/baykit/bayserver/tours/tour_req.rb
|
129
151
|
- lib/baykit/bayserver/tours/tour_res.rb
|
130
152
|
- lib/baykit/bayserver/tours/tour_store.rb
|
@@ -134,12 +156,10 @@ files:
|
|
134
156
|
- lib/baykit/bayserver/util/byte_buffer.rb
|
135
157
|
- lib/baykit/bayserver/util/cgi_util.rb
|
136
158
|
- lib/baykit/bayserver/util/char_util.rb
|
137
|
-
- lib/baykit/bayserver/util/cities.rb
|
138
159
|
- lib/baykit/bayserver/util/class_util.rb
|
139
160
|
- lib/baykit/bayserver/util/counter.rb
|
140
161
|
- lib/baykit/bayserver/util/data_consume_listener.rb
|
141
162
|
- lib/baykit/bayserver/util/executor_service.rb
|
142
|
-
- lib/baykit/bayserver/util/groups.rb
|
143
163
|
- lib/baykit/bayserver/util/gzip_compressor.rb
|
144
164
|
- lib/baykit/bayserver/util/headers.rb
|
145
165
|
- lib/baykit/bayserver/util/host_matcher.rb
|
@@ -167,7 +187,6 @@ files:
|
|
167
187
|
- lib/baykit/bayserver/util/valve.rb
|
168
188
|
- lib/baykit/bayserver/version.rb
|
169
189
|
- lib/baykit/bayserver/watercraft/boat.rb
|
170
|
-
- lib/baykit/bayserver/watercraft/ship.rb
|
171
190
|
- lib/baykit/bayserver/watercraft/yacht.rb
|
172
191
|
homepage: https://baykit.yokohama
|
173
192
|
licenses:
|
@@ -1,231 +0,0 @@
|
|
1
|
-
require 'fcntl'
|
2
|
-
require 'baykit/bayserver/agent/grand_agent'
|
3
|
-
require 'baykit/bayserver/util/io_util'
|
4
|
-
|
5
|
-
module Baykit
|
6
|
-
module BayServer
|
7
|
-
module Agent
|
8
|
-
class GrandAgentMonitor
|
9
|
-
include Baykit::BayServer::Util
|
10
|
-
|
11
|
-
class << self
|
12
|
-
attr :num_agents
|
13
|
-
attr :cur_id
|
14
|
-
attr :anchored_port_map
|
15
|
-
attr :monitors
|
16
|
-
attr :finale
|
17
|
-
end
|
18
|
-
|
19
|
-
@num_agents = 0
|
20
|
-
@cur_id = 0
|
21
|
-
@anchored_port_map = []
|
22
|
-
@monitors = {}
|
23
|
-
@finale = false
|
24
|
-
|
25
|
-
attr :agent_id
|
26
|
-
attr :anchorable
|
27
|
-
attr :communication_channel
|
28
|
-
attr :child_pid
|
29
|
-
|
30
|
-
def initialize(agt_id, anchorable, com_channel, child_pid)
|
31
|
-
@agent_id = agt_id
|
32
|
-
@anchorable = anchorable
|
33
|
-
@communication_channel = com_channel
|
34
|
-
@child_pid = child_pid
|
35
|
-
end
|
36
|
-
|
37
|
-
def to_s()
|
38
|
-
return "Monitor##{@agent_id}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def on_readable()
|
42
|
-
begin
|
43
|
-
res = IOUtil.read_int32(@communication_channel)
|
44
|
-
if res == nil || res == GrandAgent::CMD_CLOSE
|
45
|
-
BayLog.debug("%s read Close", self)
|
46
|
-
close()
|
47
|
-
agent_aborted()
|
48
|
-
else
|
49
|
-
BayLog.debug("%s read OK: %d", self, res)
|
50
|
-
end
|
51
|
-
rescue IO::WaitReadable
|
52
|
-
#BayLog.debug("%s no data", self)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def shutdown()
|
57
|
-
BayLog.debug("%s send shutdown command", self)
|
58
|
-
send(GrandAgent::CMD_SHUTDOWN)
|
59
|
-
end
|
60
|
-
|
61
|
-
def abort()
|
62
|
-
BayLog.debug("%s Send abort command", self)
|
63
|
-
send(GrandAgent::CMD_ABORT)
|
64
|
-
end
|
65
|
-
|
66
|
-
def reload_cert()
|
67
|
-
BayLog.debug("%s Send reload command", self)
|
68
|
-
send(GrandAgent::CMD_RELOAD_CERT)
|
69
|
-
end
|
70
|
-
|
71
|
-
def print_usage()
|
72
|
-
BayLog.debug("%s Send mem_usage command", self)
|
73
|
-
send(GrandAgent::CMD_MEM_USAGE)
|
74
|
-
sleep(0.5) # Lazy implementation
|
75
|
-
end
|
76
|
-
|
77
|
-
def send(cmd)
|
78
|
-
BayLog.debug("%s send command %s ch=%s", self, cmd, @communication_channel)
|
79
|
-
IOUtil.write_int32(@communication_channel, cmd)
|
80
|
-
end
|
81
|
-
|
82
|
-
def close()
|
83
|
-
@communication_channel.close()
|
84
|
-
end
|
85
|
-
|
86
|
-
def agent_aborted()
|
87
|
-
BayLog.info(BayMessage.get(:MSG_GRAND_AGENT_SHUTDOWN, @agent_id))
|
88
|
-
|
89
|
-
if @child_pid != nil
|
90
|
-
begin
|
91
|
-
Process.kill("TERM", @child_pid)
|
92
|
-
rescue => e
|
93
|
-
BayLog.debug_e(e, "Error on killing process")
|
94
|
-
end
|
95
|
-
Process.wait(@child_pid)
|
96
|
-
end
|
97
|
-
GrandAgentMonitor.monitors.delete(@agent_id)
|
98
|
-
|
99
|
-
if not GrandAgentMonitor.finale
|
100
|
-
if GrandAgentMonitor.monitors.length < GrandAgentMonitor.num_agents
|
101
|
-
begin
|
102
|
-
if !BayServer.harbor.multi_core
|
103
|
-
GrandAgent.add(-1, @anchorable)
|
104
|
-
end
|
105
|
-
GrandAgentMonitor.add(@anchorable)
|
106
|
-
rescue => e
|
107
|
-
BayLog.error_e(e)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
########################################
|
114
|
-
# Class methods
|
115
|
-
########################################
|
116
|
-
|
117
|
-
def self.init(num_agents, anchored_port_map)
|
118
|
-
@num_agents = num_agents
|
119
|
-
@anchored_port_map = anchored_port_map
|
120
|
-
@num_agents.times do
|
121
|
-
add(true)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def self.add(anchoroable)
|
126
|
-
@cur_id = @cur_id + 1
|
127
|
-
agt_id = @cur_id
|
128
|
-
if agt_id > 100
|
129
|
-
BayLog.error("Too many agents started")
|
130
|
-
exit(1)
|
131
|
-
end
|
132
|
-
|
133
|
-
if BayServer.harbor.multi_core
|
134
|
-
new_argv = BayServer.commandline_args.dup
|
135
|
-
new_argv.insert(0, "ruby")
|
136
|
-
new_argv << "-agentid=" + agt_id.to_s
|
137
|
-
|
138
|
-
ports = ""
|
139
|
-
|
140
|
-
no_close_io = {} # Port list not to close on spawned
|
141
|
-
@anchored_port_map.each_key do |ch|
|
142
|
-
no_close_io[ch] = ch
|
143
|
-
if ports != ""
|
144
|
-
ports +=","
|
145
|
-
end
|
146
|
-
ports += ch.fileno.to_s
|
147
|
-
end
|
148
|
-
new_argv << "-ports=" + ports
|
149
|
-
|
150
|
-
server = TCPServer.open("localhost", 0)
|
151
|
-
#BayLog.info("port=%d", server.local_address.ip_port)
|
152
|
-
new_argv << "-monitor_port=" + server.local_address.ip_port.to_s
|
153
|
-
|
154
|
-
if SysUtil.run_on_windows()
|
155
|
-
child = spawn(ENV, new_argv.join(" "))
|
156
|
-
else
|
157
|
-
child = spawn(ENV, new_argv.join(" "), no_close_io)
|
158
|
-
end
|
159
|
-
|
160
|
-
BayLog.debug("Process spawned cmd=%s pid=%d", new_argv, child)
|
161
|
-
|
162
|
-
client_socket = server.accept()
|
163
|
-
server.close()
|
164
|
-
|
165
|
-
else
|
166
|
-
|
167
|
-
if SysUtil::run_on_windows()
|
168
|
-
pair = Socket.socketpair(Socket::AF_INET, Socket::SOCK_STREAM, 0)
|
169
|
-
else
|
170
|
-
pair = Socket.socketpair(Socket::AF_UNIX, Socket::SOCK_STREAM, 0)
|
171
|
-
end
|
172
|
-
|
173
|
-
client_socket = pair[0]
|
174
|
-
GrandAgent.add(agt_id, anchoroable)
|
175
|
-
|
176
|
-
# Agents run on single core (thread mode)
|
177
|
-
Thread.new() do
|
178
|
-
agt = GrandAgent.get(agt_id)
|
179
|
-
agt.run_command_receiver(pair[1])
|
180
|
-
agt.run()
|
181
|
-
end
|
182
|
-
|
183
|
-
child = nil
|
184
|
-
|
185
|
-
end
|
186
|
-
|
187
|
-
@monitors[agt_id] =
|
188
|
-
GrandAgentMonitor.new(
|
189
|
-
agt_id,
|
190
|
-
anchoroable,
|
191
|
-
client_socket,
|
192
|
-
child)
|
193
|
-
end
|
194
|
-
|
195
|
-
def self.reload_cert_all()
|
196
|
-
@monitors.values.each { |mon| mon.reload_cert() }
|
197
|
-
end
|
198
|
-
|
199
|
-
def self.restart_all()
|
200
|
-
old_monitors = @monitors.dup()
|
201
|
-
|
202
|
-
#@agent_count.times {add()}
|
203
|
-
|
204
|
-
old_monitors.values.each { |mon| mon.shutdown() }
|
205
|
-
end
|
206
|
-
|
207
|
-
def self.shutdown_all()
|
208
|
-
@finale = true
|
209
|
-
@monitors.dup().values.each do |mon|
|
210
|
-
mon.shutdown()
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
def self.abort_all()
|
215
|
-
@finale = true
|
216
|
-
@monitors.dup().values.each do |mon|
|
217
|
-
mon.abort()
|
218
|
-
end
|
219
|
-
exit(1)
|
220
|
-
end
|
221
|
-
|
222
|
-
def self.print_usage_all()
|
223
|
-
@monitors.values.each do |mon|
|
224
|
-
mon.print_usage()
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'baykit/bayserver/agent/transporter/transporter'
|
2
|
-
require 'baykit/bayserver/protocol/protocol_exception'
|
3
|
-
require 'baykit/bayserver/agent/next_socket_action'
|
4
|
-
|
5
|
-
module Baykit
|
6
|
-
module BayServer
|
7
|
-
module Agent
|
8
|
-
module Transporter
|
9
|
-
class PlainTransporter < Baykit::BayServer::Agent::Transporter::Transporter
|
10
|
-
include Baykit::BayServer::Agent
|
11
|
-
include Baykit::BayServer::Protocol
|
12
|
-
include Baykit::BayServer::Util
|
13
|
-
|
14
|
-
def initialize(server_mode, bufsiz, write_only = false)
|
15
|
-
super(server_mode, bufsiz, false, write_only)
|
16
|
-
end
|
17
|
-
|
18
|
-
def init(nb_hnd, ch, lis)
|
19
|
-
super
|
20
|
-
@handshaked = true # plain socket doesn't need to handshake
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_s
|
24
|
-
return "tp[#{@data_listener}]"
|
25
|
-
end
|
26
|
-
|
27
|
-
######################################################
|
28
|
-
# Implements Transporter
|
29
|
-
######################################################
|
30
|
-
|
31
|
-
def secure()
|
32
|
-
return false
|
33
|
-
end
|
34
|
-
|
35
|
-
def handshake_nonblock
|
36
|
-
raise Sink.new("needless to handshake")
|
37
|
-
end
|
38
|
-
|
39
|
-
def read_nonblock()
|
40
|
-
#@ch.sysread(@capacity, @read_buf)
|
41
|
-
@ch.read_nonblock(@capacity, @read_buf)
|
42
|
-
return nil # client address (for UDP)
|
43
|
-
end
|
44
|
-
|
45
|
-
def write_nonblock(buf, adr)
|
46
|
-
#return @ch.syswrite(buf)
|
47
|
-
return @ch.write_nonblock(buf)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
|