About the order of execution of the modules.

Francis Daly francis at daoine.org
Sun Mar 14 20:04:14 UTC 2021


On Sun, Mar 14, 2021 at 05:43:19PM +0000, SP ADD wrote:

Hi there,

What follows is based on my reading of the docs; I may have missed
something, and I am happy to be corrected by someone who knows what
really happens.

> In my module, ngx_module_type is set to HTTP, so ngx_module_order doesn't apply.

It is not clear to me that that "so" statement is true.

Have you documentation to show that it is? What happened when you
tried it?

> I'm sorry, I'm not sure what "stock module" means, I guess it means a built-in module, i.e. a module that can be enabled or disabled just by the parameters of the "configure" script, without having to download the source code of the module, e.g. ngx_http_flv_module and ngx_http_rewrite_module.
> 

You are correct. Perhaps "standard" modules would have been a better
term for me to use.

> If I am correct, I will list below the questions I would like to ask and hopefully the questions below are clear and unambiguous.

What control do you want, specifically?

My reading suggests that the "static" module order is "from the
./configure line, --add-module order", and the "dynamic" module order is
"from the nginx.conf file, load_module order", where the dynamic modules
have the option to list which named modules they should run before.

(And: order is only relevant within the same phase; you did mention
that already.)

If you want more control than that, you may want to ship an nginx binary
configured the way you want it, without load_module support.

(And you probably don't want to do that.)

> * How to control the order of execution between the dynamic stock module and my dynamic module.

As the developer, I think that you do not know which stock modules are
dynamic. But you do know the names of the (current) stock modules.

If you want to be "after" a stock module, "load_module" after it in
nginx.conf.

If you want to be "before" a stock module, set your ngx_module_order to
your name then the stock module name.

> * How to control the order of execution between the dynamic stock module and my static module.

You don't.

You will be "before" (absent circumstances you can't control).

> * How to control the order of execution between my dynamic non-stock modules and my dynamic modules.

(Corrected to remove the first "my".)

load_module order, unless you-or-they know each other's names and set
ngx_module_order; in that case, whichever was last in load_module gets
to be before whichever names they nominate.

> * How to control the order of execution between dynamic non-stock modules and my static modules.

Same as dynamic stock module, except you probably do not know their
names in advance.

> * How to control the order of execution between static stock modules and my dynamic modules.

You will be "after", unless you set your ngx_module_order.

> * How to control the order of execution between static stock modules and my static modules.

./configure order.

> Regarding the last question, have I looked at https://forum.nginx.org/read.php?2,246978,246999#msg-246999 and can the answers there be used to control the order between the static stock modules and my static modules?
> 

I suspect that what is there is still fundamentally correct, yes.

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list