mirror of
https://github.com/ONLYOFFICE/Docker-Docs.git
synced 2025-04-18 15:04:02 +03:00
Fix rr when index count more than table count
Co-authored-by: danilapog <danil.titarenko@onlyoffice.com> Co-committed-by: danilapog <danil.titarenko@onlyoffice.com>
This commit is contained in:
parent
14fb06040f
commit
7f916cc1b6
@ -21,14 +21,16 @@ def set_nginx_parameter():
|
||||
logger_endpoints_ds.info('Running the setting of values in Nginx config')
|
||||
nginx_worker_processes = os.environ.get('BALANCER_WORKER_PROCESSES')
|
||||
nginx_worker_connections = os.environ.get('BALANCER_WORKER_CONNECTIONS')
|
||||
nginx_worker_timeout = os.environ.get('BALANCER_WORKER_TIMEOUT')
|
||||
path = '/usr/local/openresty/nginx/conf/nginx.conf'
|
||||
try:
|
||||
with open(path, "r") as nginx_conf_read:
|
||||
nginx_config = nginx_conf_read.read()
|
||||
worker_processes = re.sub(r"worker_processes.*", f'worker_processes {nginx_worker_processes};', nginx_config)
|
||||
worker_connections = re.sub(r"worker_connections.*", f'worker_connections {nginx_worker_connections};', worker_processes)
|
||||
worker_shutdown = re.sub(r"worker_shutdown_timeout.*", f'worker_shutdown_timeout {nginx_worker_timeout};', worker_connections)
|
||||
with open(path, "w") as config_write:
|
||||
config_write.write(worker_connections)
|
||||
config_write.write(worker_shutdown)
|
||||
except Exception as msg_set_nginx_conf:
|
||||
logger_endpoints_ds.error(f'Failed when trying to set a value in the Nginx config... {msg_set_nginx_conf}\n')
|
||||
else:
|
||||
|
@ -84,18 +84,28 @@ function _M.balance_ep()
|
||||
end
|
||||
|
||||
local idx = rr_reserved_dict:get("last_used_index") or 1
|
||||
local max_index = #reserved_addresses
|
||||
|
||||
if idx > max_index then
|
||||
idx = 1
|
||||
end
|
||||
|
||||
random_endpoint = reserved_addresses[idx]
|
||||
|
||||
-- Update to the next index for the next request
|
||||
idx = idx + 1
|
||||
if idx > #matching_addresses then
|
||||
if idx > #reserved_addresses then
|
||||
idx = 1
|
||||
end
|
||||
|
||||
rr_reserved_dict:set("last_used_index", idx)
|
||||
else
|
||||
local idx = rr_live_dict:get("last_used_index") or 1
|
||||
local max_index = #matching_addresses
|
||||
|
||||
if idx > max_index then
|
||||
idx = 1
|
||||
end
|
||||
|
||||
random_endpoint = matching_addresses[idx]
|
||||
|
||||
|
@ -2,7 +2,7 @@ worker_processes 1;
|
||||
|
||||
worker_rlimit_nofile 1047552;
|
||||
|
||||
worker_shutdown_timeout 300;
|
||||
worker_shutdown_timeout 18000;
|
||||
|
||||
# Enables the use of JIT for regular expressions to speed-up their processing.
|
||||
pcre_jit on;
|
||||
|
Loading…
x
Reference in New Issue
Block a user