博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

nginx 模块类型 事件驱动

Posted on 2016-03-03 14:22  bw_0927  阅读(428)  评论(0)    收藏  举报

 

  • NGX_CORE_MODULE
ngx_module_t  ngx_events_module = {
    NGX_MODULE_V1,
    &ngx_events_module_ctx,                /* module context */
    ngx_events_commands,                   /* module directives */
    NGX_CORE_MODULE,                       /* module type */
    NULL,                                  /* init master */
    NULL,                                  /* init module */
    NULL,                                  /* init process */
    NULL,                                  /* init thread */
    NULL,                                  /* exit thread */
    NULL,                                  /* exit process */
    NULL,                                  /* exit master */
    NGX_MODULE_V1_PADDING
};

  

ngx_module_t  ngx_errlog_module = {
    NGX_MODULE_V1,
    &ngx_errlog_module_ctx,                /* module context */
    ngx_errlog_commands,                   /* module directives */
    NGX_CORE_MODULE,                       /* module type */
    NULL,                                  /* init master */
    NULL,                                  /* init module */
    NULL,                                  /* init process */
    NULL,                                  /* init thread */
    NULL,                                  /* exit thread */
    NULL,                                  /* exit process */
    NULL,                                  /* exit master */
    NGX_MODULE_V1_PADDING
};

   

ngx_module_t  ngx_core_module = {
    NGX_MODULE_V1,
    &ngx_core_module_ctx,                  /* module context */
    ngx_core_commands,                     /* module directives */
    NGX_CORE_MODULE,                       /* module type */
    NULL,                                  /* init master */
    NULL,                                  /* init module */
    NULL,                                  /* init process */
    NULL,                                  /* init thread */
    NULL,                                  /* exit thread */
    NULL,                                  /* exit process */
    NULL,                                  /* exit master */
    NGX_MODULE_V1_PADDING
};

  

ngx_module_t  ngx_regex_module = {};

   ngx_module_t ngx_mail_module = {};


ngx_module_t ngx_google_perftools_module = {};

   ngx_module_t ngx_openssl_module = {};

  

ngx_module_t  ngx_http_module = {
    NGX_MODULE_V1,
    &ngx_http_module_ctx,                  /* module context */
    ngx_http_commands,                     /* module directives */
    NGX_CORE_MODULE,                       /* module type */
    NULL,                                  /* init master */
    NULL,                                  /* init module */
    NULL,                                  /* init process */
    NULL,                                  /* init thread */
    NULL,                                  /* exit thread */
    NULL,                                  /* exit process */
    NULL,                                  /* exit master */
    NGX_MODULE_V1_PADDING
};

  

  • NGX_CONF_MODULE
  • NGX_HTTP_MODULE
ngx_module_t ngx_http_core_module = {};

ngx_module_t ngx_http_spdy_module = {}; ngx_module_t ngx_http_spdy_filter_module = {};
....NGX_HTTP_MODULE类型的模块很多

  

  •  NGX_EVENT_MODULE
ngx_module_t  ngx_event_core_module = {
    NGX_MODULE_V1,
    &ngx_event_core_module_ctx,            /* module context */
    ngx_event_core_commands,               /* module directives */
    NGX_EVENT_MODULE,                      /* module type */
    NULL,                                  /* init master */
    ngx_event_module_init,                 /* init module */
    ngx_event_process_init,                /* init process */
    NULL,                                  /* init thread */
    NULL,                                  /* exit thread */
    NULL,                                  /* exit process */
    NULL,                                  /* exit master */
    NGX_MODULE_V1_PADDING
};

ngx_module_t  ngx_aio_module = {};
ngx_module_t  ngx_kqueue_module = {};
ngx_module_t  ngx_select_module = {};
ngx_module_t  ngx_devpoll_module = {};
ngx_module_t  ngx_rtsig_module = {};
ngx_module_t  ngx_poll_module = {};
ngx_module_t  ngx_epoll_module = {};
  • NGX_MAIL_MODULE
ngx_module_t  ngx_mail_imap_module = {
    NGX_MODULE_V1,
    &ngx_mail_imap_module_ctx,             /* module context */
    ngx_mail_imap_commands,                /* module directives */
    NGX_MAIL_MODULE,                       /* module type */
    NULL,                                  /* init master */
    NULL,                                  /* init module */
    NULL,                                  /* init process */
    NULL,                                  /* init thread */
    NULL,                                  /* exit thread */
    NULL,                                  /* exit process */
    NULL,                                  /* exit master */
    NGX_MODULE_V1_PADDING
};
ngx_module_t  ngx_mail_core_module = {};
ngx_module_t  ngx_mail_ssl_module = {};
ngx_module_t  ngx_mail_proxy_module = {};
ngx_module_t  ngx_mail_pop3_module = {};
ngx_module_t  ngx_mail_smtp_module = {};
ngx_module_t  ngx_mail_auth_http_module = {};

  

 

 

http://blog.csdn.net/fjslovejhl/article/details/8134008

 

 

 

ngx_events_module模块是core类型的模块;ngx_event_core_module为event类型的模块,它是所有事件模块的管理者;ngx_epoll_module也是event类型的模块,它是具体的事件模块

 

启动时候会调用所有core模块的create_conf函数,并会解析配置文件,调用命令的set回调函数,还会调用core模块的init_conf函数,以及调用所有模块的init_module(其实只有ngx_event_core_module模块有该函数)函数,

而且最后在所有的wokre进程中还会调用所有模块的ngx_worker_process_init函数。因为ngx_events_module模块没有create_conf函数,所以这里就没事件模块什么事情了。

 

所有http模块都是ngx_http_module_t类型,所有的属性都是回调函数,在http模块初始化过程的不同阶段调用。