Added advanced settings for standalone connector
- max_concurrent_connections=100 - keep_alive_timeout=15 - max_tcp_clients=100 - socket_timeout=300 - max_keep_alive_requests=300 And then can be set via the options as well, and via .ini file. Also improved the verbose console output system.
This commit is contained in:
@@ -25,6 +25,8 @@ inherit
|
||||
launchable
|
||||
end
|
||||
|
||||
WGI_STANDALONE_HTTPD_LOGGER_CONSTANTS
|
||||
|
||||
create
|
||||
make,
|
||||
make_and_launch
|
||||
@@ -34,12 +36,20 @@ feature {NONE} -- Initialization
|
||||
initialize
|
||||
local
|
||||
conn: like connector
|
||||
s: READABLE_STRING_GENERAL
|
||||
do
|
||||
create on_launched_actions
|
||||
create on_stopped_actions
|
||||
|
||||
port_number := 80 --| Default, but quite often, this port is already used ...
|
||||
keep_alive_timeout := 5_000 -- 5 seconds.
|
||||
max_concurrent_connections := 100
|
||||
max_tcp_clients := 100
|
||||
socket_timeout := 300 -- 300 seconds
|
||||
keep_alive_timeout := 15 -- 15 seconds.
|
||||
max_keep_alive_requests := 100
|
||||
verbose := False
|
||||
verbose_level := notice_level
|
||||
|
||||
base_url := ""
|
||||
|
||||
if attached options as opts then
|
||||
@@ -50,13 +60,44 @@ feature {NONE} -- Initialization
|
||||
base_url := l_base_str.as_string_8
|
||||
end
|
||||
verbose := opts.option_boolean_value ("verbose", verbose)
|
||||
-- See `{HTTPD_REQUEST_HANDLER_I}.*_verbose_level`
|
||||
|
||||
if opts.has_integer_option ("verbose_level") then
|
||||
verbose_level := opts.option_integer_value ("verbose_level", verbose_level)
|
||||
elseif attached {READABLE_STRING_GENERAL} opts.option ("verbose_level") as s_verbose_level then
|
||||
verbose_level := 0 -- Reset
|
||||
across
|
||||
s_verbose_level.split ('+') as ic
|
||||
loop
|
||||
s := ic.item
|
||||
if s.is_case_insensitive_equal ("alert") then
|
||||
verbose_level := verbose_level | alert_level
|
||||
elseif s.is_case_insensitive_equal ("critical") then
|
||||
verbose_level := verbose_level | critical_level
|
||||
elseif s.is_case_insensitive_equal ("error") then
|
||||
verbose_level := verbose_level | error_level
|
||||
elseif s.is_case_insensitive_equal ("warning") then
|
||||
verbose_level := verbose_level | warning_level
|
||||
elseif s.is_case_insensitive_equal ("notice") then
|
||||
verbose_level := verbose_level | notice_level
|
||||
elseif s.is_case_insensitive_equal ("information") then
|
||||
verbose_level := verbose_level | information_level
|
||||
elseif s.is_case_insensitive_equal ("debug") then
|
||||
verbose_level := verbose_level | debug_level
|
||||
else
|
||||
end
|
||||
end
|
||||
end
|
||||
port_number := opts.option_integer_value ("port", port_number)
|
||||
|
||||
if opts.option_boolean_value ("force_single_threaded", single_threaded) then
|
||||
if opts.option_boolean_value ("force_single_threaded", False) then
|
||||
force_single_threaded
|
||||
end
|
||||
max_concurrent_connections := opts.option_integer_value ("max_concurrent_connections", max_concurrent_connections)
|
||||
max_tcp_clients := opts.option_integer_value ("max_tcp_clients", max_tcp_clients)
|
||||
socket_timeout := opts.option_integer_value ("socket_timeout", socket_timeout)
|
||||
keep_alive_timeout := opts.option_integer_value ("keep_alive_timeout", keep_alive_timeout)
|
||||
max_keep_alive_requests := opts.option_integer_value ("max_keep_alive_requests", max_keep_alive_requests)
|
||||
end
|
||||
|
||||
create conn.make
|
||||
@@ -78,13 +119,14 @@ feature -- Execution
|
||||
update_configuration (cfg: like connector.configuration)
|
||||
do
|
||||
cfg.set_is_verbose (verbose)
|
||||
if attached server_name as l_server_name then
|
||||
cfg.set_http_server_name (l_server_name)
|
||||
end
|
||||
cfg.set_verbose_level (verbose_level)
|
||||
cfg.set_http_server_name (server_name)
|
||||
cfg.http_server_port := port_number
|
||||
cfg.set_max_concurrent_connections (max_concurrent_connections)
|
||||
cfg.set_max_tcp_clients (max_tcp_clients)
|
||||
cfg.set_socket_timeout (socket_timeout)
|
||||
cfg.set_keep_alive_timeout (keep_alive_timeout)
|
||||
-- conn.update_configuration (cfg)
|
||||
cfg.set_max_keep_alive_requests (max_keep_alive_requests)
|
||||
end
|
||||
|
||||
launch
|
||||
@@ -131,16 +173,21 @@ feature {NONE} -- Implementation
|
||||
base_url: READABLE_STRING_8
|
||||
|
||||
verbose: BOOLEAN
|
||||
verbose_level: INTEGER
|
||||
-- Help defining the verbosity.
|
||||
-- The higher, the more output.
|
||||
|
||||
max_concurrent_connections: INTEGER
|
||||
max_tcp_clients: INTEGER
|
||||
socket_timeout: INTEGER
|
||||
keep_alive_timeout: INTEGER
|
||||
max_keep_alive_requests: INTEGER
|
||||
|
||||
single_threaded: BOOLEAN
|
||||
do
|
||||
Result := max_concurrent_connections = 0
|
||||
end
|
||||
|
||||
max_concurrent_connections: INTEGER
|
||||
|
||||
keep_alive_timeout: INTEGER
|
||||
|
||||
feature -- Status report
|
||||
|
||||
connector: WGI_STANDALONE_CONNECTOR [G]
|
||||
|
||||
@@ -85,6 +85,21 @@ feature -- Access
|
||||
|
||||
feature -- Helpers
|
||||
|
||||
has_integer_option (a_opt_name: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Is there any INTEGER value associated to option name `a_opt_name'?
|
||||
local
|
||||
s: READABLE_STRING_GENERAL
|
||||
do
|
||||
if attached option (a_opt_name) as opt then
|
||||
if attached {INTEGER} opt as i then
|
||||
Result := True
|
||||
else
|
||||
s := opt.out
|
||||
Result := s.is_integer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
option_integer_value (a_opt_name: READABLE_STRING_GENERAL; a_default: INTEGER): INTEGER
|
||||
-- INTEGER value associated to option name `a_opt_name', other return `a_default'.
|
||||
local
|
||||
|
||||
Reference in New Issue
Block a user