text
stringlengths
0
834k
if file_gen then file_gen() end
end
end
_EOC_
my $env_list = '';
for my $var (sort keys %ENV) {
#warn $var;
$env_list .= ""env $var;\n"";
}
my $main_include_directives = resolve_includes 'main', \@main_includes;
my $http_include_directives = resolve_includes 'http', \@http_includes;
my $http_conf_lines = join """", map { "" $_\n"" } @http_confs;
my $stream_conf_lines = join """", map { "" $_\n"" } @stream_confs;
my $main_conf_lines = join """", map { "" $_\n"" } @main_confs;
my $conf_file;
if ($is_win32) {
$conf_file = File::Spec->catfile($conf_dir, ""nginx.conf"");
} else {
$conf_file = ""$conf_dir/nginx.conf"";
}
open my $out, "">$conf_file""
or die ""Cannot open $conf_file for writing: $!\n"";
print $out <<_EOC_;
daemon off;
master_process off;
worker_processes 1;
pid logs/nginx.pid;
$env_list
error_log stderr $errlog_level;
#error_log stderr debug;
events {
worker_connections $conns;
}
$main_conf_lines
$main_include_directives
_EOC_
if (!$no_stream) {
print $out <<_EOC_;
stream {
access_log off;
lua_socket_log_errors off;
resolver @nameservers;
lua_regex_cache_max_entries 40960;
$lua_package_path_config
$stream_conf_lines
}
_EOC_
}
print $out <<_EOC_;
http {
access_log off;
lua_socket_log_errors off;
resolver @nameservers;
lua_regex_cache_max_entries 40960;
$lua_shared_dicts
$lua_package_path_config
$http_conf_lines
$http_include_directives
init_by_lua_block {
ngx.config.is_console = true
local stdout = io.stdout
local ngx_null = ngx.null
local maxn = table.maxn
local unpack = unpack
local concat = table.concat
local expand_table
function expand_table(src, inplace)
local n = maxn(src)
local dst = inplace and src or {}
for i = 1, n do
local arg = src[i]
local typ = type(arg)
if arg == nil then
dst[i] = ""nil""
elseif typ == ""boolean"" then
if arg then
dst[i] = ""true""
else
dst[i] = ""false""
end
elseif arg == ngx_null then