Welcome! Log In Create A New Profile

Advanced

init module callback called twice

April 08, 2021 05:54AM
Hello,

I'm developing a little custom module for nginx, and I need to execute some user code once my module is loaded. I do this by attaching to the hook in ngx_module_t structure:

ngx_module_t ngx_http_hello_world_module = {
...
NULL, /* init master */
init_module, /* init module */
NULL, /* init process */
...
}

static ngx_int_t init_module(ngx_cycle_t *cycle) {
ngx_log_stderr (0, "Initializing module") ; }

Surprisingly my callback is called twice. First time it follows log message

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: Initializing module

and then

nginx: configuration file /etc/nginx/nginx.conf test is successful
nginx: Initializing module

Is there a way to recognize that I'm called in some different context (e.g. some value from ngx_cycle_t structure)?
Or may be I'm doing something completely wrong?

Thanks
Andrew
Subject Author Posted

init module callback called twice

xdrew April 08, 2021 05:54AM

Re: init module callback called twice

Maxim Dounin April 08, 2021 09:12AM

Re: init module callback called twice

xdrew April 08, 2021 09:48AM

Re: init module callback called twice

Maxim Dounin April 08, 2021 11:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 104
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready