add nginx error log level

This commit is contained in:
GLYASAI 2020-03-07 23:26:53 +08:00
parent 9a62437fac
commit 78413473e4
4 changed files with 13 additions and 9 deletions

View File

@ -54,6 +54,7 @@ type Config struct {
WorkerProcesses int
WorkerRlimitNofile int
ErrorLog string
ErrorLogLevel string
WorkerConnections int
//essential for linux, optmized to serve many clients with each thread
EnableEpool bool
@ -68,11 +69,11 @@ type Config struct {
EnableMetrics bool
NodeName string
HostIP string
IgnoreInterface []string
ShareMemory uint64
SyncRateLimit float32
NodeName string
HostIP string
IgnoreInterface []string
ShareMemory uint64
SyncRateLimit float32
}
// ListenPorts describe the ports required to run the gateway controller
@ -98,7 +99,8 @@ func (g *GWServer) AddFlags(fs *pflag.FlagSet) {
fs.IntVar(&g.WorkerRlimitNofile, "worker-rlimit-nofile", 200000, "Number of file descriptors used for Nginx. This is set in the OS with 'ulimit -n 200000'")
fs.BoolVar(&g.EnableEpool, "enable-epool", true, "essential for linux, optmized to serve many clients with each thread")
fs.BoolVar(&g.EnableMultiAccept, "enable-multi-accept", true, "Accept as many connections as possible, after nginx gets notification about a new connection.")
fs.StringVar(&g.ErrorLog, "error-log", "/dev/stderr crit", "only log critical errors")
fs.StringVar(&g.ErrorLog, "error-log", "/dev/stderr", "nginx log file, stderr or syslog")
fs.StringVar(&g.ErrorLogLevel, "errlog-level", "crit", "log level")
fs.StringVar(&g.NginxUser, "nginx-user", "root", "nginx user name")
fs.IntVar(&g.KeepaliveRequests, "keepalive-requests", 10000, "Number of requests a client can make over the keep-alive connection. ")
fs.IntVar(&g.KeepaliveTimeout, "keepalive-timeout", 30, "Timeout for keep-alive connections. Server will close connections after this time.")

View File

@ -12,6 +12,7 @@ type Nginx struct {
WorkerProcesses int
WorkerRlimitNofile int
ErrorLog string
ErrorLogLevel string
User string
EventLog EventLog
Events Events
@ -50,6 +51,7 @@ func NewNginx(conf option.Config) *Nginx {
WorkerRlimitNofile: conf.WorkerRlimitNofile,
User: conf.NginxUser,
ErrorLog: conf.ErrorLog,
ErrorLogLevel: conf.ErrorLogLevel,
Events: Events{
WorkerConnections: conf.WorkerConnections,
EnableEpoll: conf.EnableEpool,

View File

@ -61,7 +61,6 @@ local function sync_backend(backend)
return
end
ngx.log(ngx.INFO, string.format("backend ", backend.name))
local implementation = get_implementation(backend)
local balancer = balancers[backend.name]
@ -138,6 +137,7 @@ end
function _M.balance()
local balancer = get_balancer()
ngx.log(ngx.DEBUG, string.format("found balancer %s for %s", balancer.name, ngx.var.proxy_upstream_name))
if not balancer then
local backend_name = ngx.var.proxy_upstream_name
ngx.log(ngx.ERR, string.format("not balancer %s", backend_name))
@ -151,7 +151,7 @@ function _M.balance()
end
ngx_balancer.set_more_tries(1)
ngx.log(ngx.DEBUG, string.format("select peer %s", peer))
ngx.log(ngx.DEBUG, string.format("select peer %s for %s", peer, ngx.var.proxy_upstream_name))
local ok, err = ngx_balancer.set_current_peer(peer)
if not ok then
ngx.log(ngx.ERR, string.format("error while setting current upstream peer %s: %s", peer, err))

View File

@ -1,6 +1,6 @@
{{ if .User }} user {{.User}};{{ end }}
worker_processes {{.WorkerProcesses}};
error_log {{.ErrorLog}};
error_log {{.ErrorLog}} {{.ErrorLogLevel}};
worker_rlimit_nofile {{.WorkerRlimitNofile}};
daemon off;