当前位置: 首页> 房产> 家装 > 哈尔滨网站建设好_公司网站怎么规范管理的_2023年7月疫情爆发_谷歌优化的最佳方案

哈尔滨网站建设好_公司网站怎么规范管理的_2023年7月疫情爆发_谷歌优化的最佳方案

时间:2025/9/7 18:24:24来源:https://blog.csdn.net/weixin_41812346/article/details/146768773 浏览次数:0次
哈尔滨网站建设好_公司网站怎么规范管理的_2023年7月疫情爆发_谷歌优化的最佳方案
main 函数在
src\core\nginx.c

int ngx_cdecl
main(int argc, char *const *argv)
{ngx_buf_t        *b;ngx_log_t        *log;ngx_uint_t        i;ngx_cycle_t      *cycle, init_cycle;ngx_conf_dump_t  *cd;ngx_core_conf_t  *ccf;ngx_debug_init();if (ngx_strerror_init() != NGX_OK) {return 1;}if (ngx_get_options(argc, argv) != NGX_OK) {return 1;}if (ngx_show_version) {ngx_show_version_info();if (!ngx_test_config) {return 0;}}/* TODO */ ngx_max_sockets = -1;ngx_time_init();#if (NGX_PCRE)ngx_regex_init();
#endifngx_pid = ngx_getpid();ngx_parent = ngx_getppid();log = ngx_log_init(ngx_prefix, ngx_error_log);if (log == NULL) {return 1;}/* STUB */
#if (NGX_OPENSSL)ngx_ssl_init(log);
#endif/** init_cycle->log is required for signal handlers and* ngx_process_options()*/ngx_memzero(&init_cycle, sizeof(ngx_cycle_t));init_cycle.log = log;ngx_cycle = &init_cycle;init_cycle.pool = ngx_create_pool(1024, log);if (init_cycle.pool == NULL) {return 1;}if (ngx_save_argv(&init_cycle, argc, argv) != NGX_OK) {return 1;}if (ngx_process_options(&init_cycle) != NGX_OK) {return 1;}if (ngx_os_init(log) != NGX_OK) {return 1;}/** ngx_crc32_table_init() requires ngx_cacheline_size set in ngx_os_init()*/if (ngx_crc32_table_init() != NGX_OK) {return 1;}/** ngx_slab_sizes_init() requires ngx_pagesize set in ngx_os_init()*/ngx_slab_sizes_init();if (ngx_add_inherited_sockets(&init_cycle) != NGX_OK) {return 1;}if (ngx_preinit_modules() != NGX_OK) {return 1;}cycle = ngx_init_cycle(&init_cycle);if (cycle == NULL) {if (ngx_test_config) {ngx_log_stderr(0, "configuration file %s test failed",init_cycle.conf_file.data);}return 1;}if (ngx_test_config) {if (!ngx_quiet_mode) {ngx_log_stderr(0, "configuration file %s test is successful",cycle->conf_file.data);}if (ngx_dump_config) {cd = cycle->config_dump.elts;for (i = 0; i < cycle->config_dump.nelts; i++) {ngx_write_stdout("# configuration file ");(void) ngx_write_fd(ngx_stdout, cd[i].name.data,cd[i].name.len);ngx_write_stdout(":" NGX_LINEFEED);b = cd[i].buffer;(void) ngx_write_fd(ngx_stdout, b->pos, b->last - b->pos);ngx_write_stdout(NGX_LINEFEED);}}return 0;}if (ngx_signal) {return ngx_signal_process(cycle, ngx_signal);}ngx_os_status(cycle->log);ngx_cycle = cycle;ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);if (ccf->master && ngx_process == NGX_PROCESS_SINGLE) {ngx_process = NGX_PROCESS_MASTER;}#if !(NGX_WIN32)if (ngx_init_signals(cycle->log) != NGX_OK) {return 1;}if (!ngx_inherited && ccf->daemon) {if (ngx_daemon(cycle->log) != NGX_OK) {return 1;}ngx_daemonized = 1;}if (ngx_inherited) {ngx_daemonized = 1;}#endifif (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) {return 1;}if (ngx_log_redirect_stderr(cycle) != NGX_OK) {return 1;}if (log->file->fd != ngx_stderr) {if (ngx_close_file(log->file->fd) == NGX_FILE_ERROR) {ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,ngx_close_file_n " built-in log failed");}}ngx_use_stderr = 0;if (ngx_process == NGX_PROCESS_SINGLE) {ngx_single_process_cycle(cycle);} else {ngx_master_process_cycle(cycle);}return 0;
}

ngx_cdecl 

Ubuntu 下 nginx-1.24.0 源码分析 main函数 — ngx_cdecl 宏-CSDN博客


ngx_debug_init();

Ubuntu 下 nginx-1.24.0 源码分析 ngx_debug_init();-CSDN博客


    if (ngx_strerror_init() != NGX_OK) {return 1;}

Ubuntu 下 nginx-1.24.0 源码分析 - ngx_strerror_init()函数-CSDN博客


    if (ngx_get_options(argc, argv) != NGX_OK) {return 1;}

 解析用户在命令行中输入的参数

ngx_get_options-CSDN博客


    if (ngx_show_version) {ngx_show_version_info();if (!ngx_test_config) {return 0;}}
此时

ngx_show_version=0

ngx_show_version 未设置,是 0

条件不成立


    /* TODO */ ngx_max_sockets = -1;
初始化全局变量 ngx_max_sockets
ngx_max_sockets 是一个全局变量,用于存储 Nginx 能够处理的最大文件描述符(socket)数量
将 ngx_max_sockets 初始化为 -1 表示在程序启动时,还没有确定实际的最大文件描述符数量
-1 通常用作一个初始值或无效值,表示该变量尚未被正确初始化或配置
在后续的代码中,Nginx 会根据操作系统的限制和配置文件中的设置来更新 ngx_max_sockets 的值

    ngx_time_init();

初始化 Nginx 的时间缓存机制

关键字:哈尔滨网站建设好_公司网站怎么规范管理的_2023年7月疫情爆发_谷歌优化的最佳方案

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: