nginx的启动
2016-07-10 23:45:58 0 举报
nginx启动过程主要包括以下几个步骤:首先,读取配置文件nginx.conf,解析并合并其中的指令;接着,初始化各种全局变量和缓存;然后,根据配置文件中的server块信息,创建相应的监听socket;最后,启动一个master进程和多个worker进程,实现并发处理请求。在启动过程中,nginx会检查配置文件的语法是否正确,以及所需的依赖库是否已安装。如果一切正常,nginx将以daemon模式在后台运行,监听指定的端口,等待客户端发起请求。
作者其他创作
大纲/内容
ngx_conf_param几乎什么都不做 解析nginx命令行参数\"-g\"加入的配置
ngx_create_pool
ngx_init_cycle
ngx_list_init(&cycle-shared_memory)
对confi进行初始化ngx_conf_t
cycle-listening.eltsf分配内存
调用钩子create_conf
ngx_list_t
分配conf_ctx内存大小为 43× 指针大小
ngx_list_init(cycle-open_files)
ngx_time_update
初始化cycle-hostname
ngx_list_part_t *last; //指向链表最后一个节点(part) ngx_list_part_t part; //链表头中包含的第一个节点(part) size_t size; //每个元素大小 ngx_uint_t nalloc; //链表所含空间个数,即实际分配的小空间的个数 ngx_pool_t *pool; //该链表节点空间在此内存池中分配
ngx_timeofday
cf-conf_file -buffer
ngx_conf_parse
ngx_list_part_s
获取当前时间并保存小时到buf 里
ngx_conf_parse真正的解析
ngx_list_part_t *next;
ngx_conf_read_token
for ( ;; ) {
循环所有ngx_modules 匹配core module core
从pool中获取n*size个内存
ngx_timezone_update
*elts
ngx_queue_init(&cycle-reusable_connections_queue)
rc = ngx_conf_read_token(cf);
ngx_uint_t nelts
循环遍历ngx_modules 实际一个都没遍历到ngx_core_module,ngx_errlog_module,ngx_events_module和ngx_http_modul
0 条评论
下一页