-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Template init lua cfg and fix configs
- Loading branch information
Showing
13 changed files
with
201 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local lua_ingress = require("lua_ingress") | ||
local balancer = require("balancer") | ||
|
||
lua_ingress.rewrite() | ||
balancer.rewrite() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,54 @@ | ||
local function initialize_ingress(statusport, enablemetrics, ocsp, ingress) | ||
collectgarbage("collect") | ||
-- init modules | ||
local ok, res | ||
ok, res = pcall(require, "lua_ingress") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
lua_ingress = res | ||
lua_ingress.set_config(ingress) | ||
end | ||
|
||
ok, res = pcall(require, "configuration") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
configuration = res | ||
configuration.prohibited_localhost_port = statusport | ||
end | ||
|
||
ok, res = pcall(require, "balancer") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
balancer = res | ||
end | ||
local cjson = require("cjson.safe") | ||
|
||
if enablemetrics then | ||
ok, res = pcall(require, "monitor") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
monitor = res | ||
end | ||
end | ||
collectgarbage("collect") | ||
local f = io.open("/etc/nginx/lua/cfg.json", "r") | ||
local content = f:read("*a") | ||
f:close() | ||
local configfile = cjson.decode(content) | ||
|
||
ok, res = pcall(require, "certificate") | ||
local luaconfig = ngx.shared.luaconfig | ||
luaconfig:set("enablemetrics", configfile.enable_metrics) | ||
luaconfig:set("listen_https_ports", configfile.listen_ports.https) | ||
luaconfig:set("use_forwarded_headers", configfile.use_forwarded_headers) | ||
-- init modules | ||
local ok, res | ||
ok, res = pcall(require, "lua_ingress") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
lua_ingress = res | ||
lua_ingress.set_config(configfile) | ||
end | ||
ok, res = pcall(require, "configuration") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
configuration = res | ||
if not configfile.listen_ports.status_port then | ||
error("required status port not found") | ||
end | ||
configuration.prohibited_localhost_port = configfile.listen_ports.status_port | ||
end | ||
ok, res = pcall(require, "balancer") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
balancer = res | ||
end | ||
if configfile.enable_metrics then | ||
ok, res = pcall(require, "monitor") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
error("require failed: " .. tostring(res)) | ||
else | ||
certificate = res | ||
certificate.is_ocsp_stapling_enabled = ocsp | ||
monitor = res | ||
end | ||
end | ||
|
||
return { initialize_ingress = initialize_ingress } | ||
ok, res = pcall(require, "certificate") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
certificate = res | ||
if configfile.enable_ocsp then | ||
certificate.is_ocsp_stapling_enabled = configfile.enable_ocsp | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
local function initialize_stream(statusport) | ||
collectgarbage("collect") | ||
|
||
-- init modules | ||
local ok, res | ||
|
||
ok, res = pcall(require, "configuration") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
configuration = res | ||
end | ||
|
||
ok, res = pcall(require, "tcp_udp_configuration") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
tcp_udp_configuration = res | ||
tcp_udp_configuration.prohibited_localhost_port = statusport | ||
|
||
end | ||
|
||
ok, res = pcall(require, "tcp_udp_balancer") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
tcp_udp_balancer = res | ||
local cjson = require("cjson.safe") | ||
collectgarbage("collect") | ||
local f = io.open("/etc/nginx/lua/cfg.json", "r") | ||
local content = f:read("*a") | ||
f:close() | ||
local configfile = cjson.decode(content) | ||
-- init modules | ||
local ok, res | ||
ok, res = pcall(require, "configuration") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
configuration = res | ||
end | ||
ok, res = pcall(require, "tcp_udp_configuration") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
tcp_udp_configuration = res | ||
if not configfile.listen_ports.status_port then | ||
error("required status port not found") | ||
end | ||
tcp_udp_configuration.prohibited_localhost_port = configfile.listen_ports.status_port | ||
end | ||
ok, res = pcall(require, "tcp_udp_balancer") | ||
if not ok then | ||
error("require failed: " .. tostring(res)) | ||
else | ||
tcp_udp_balancer = res | ||
end | ||
|
||
return { initialize_stream = initialize_stream } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
local function initialize_worker(enablemetrics, monitorbatchsize) | ||
local lua_ingress = require("lua_ingress") | ||
local balancer = require("balancer") | ||
local monitor = require("monitor") | ||
lua_ingress.init_worker() | ||
balancer.init_worker() | ||
if enablemetrics then | ||
monitor.init_worker(monitorbatchsize) | ||
end | ||
end | ||
local cjson = require("cjson.safe") | ||
|
||
return { initialize_worker = initialize_worker } | ||
local f = io.open("/etc/nginx/lua/cfg.json", "r") | ||
local content = f:read("*a") | ||
f:close() | ||
local configfile = cjson.decode(content) | ||
|
||
local lua_ingress = require("lua_ingress") | ||
local balancer = require("balancer") | ||
local monitor = require("monitor") | ||
lua_ingress.init_worker() | ||
balancer.init_worker() | ||
if configfile.enable_metrics and configfile.monitor_batch_max_size then | ||
monitor.init_worker(configfile.monitor_batch_max_size) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.