eugaia at gmail.com
Wed Feb 18 17:14:42 MSK 2009
> I have similar needs, and would also like to have my module install a
> callback that gets executed once per second (like the "trigger"
> callback for lighttpd modules).
If you want to have a callback that executes regular code, you could start a new
thread during the startup process. One example might be to create a
post-configuration 'init' function, which is called after the configurations
have been merged (in your ngx_http_<your-module>_module_ctx structure, it would
be the second one on the list).
In the function that you call, spawn off a new thread, which itself has some
kind of infinite loop. You'd want to have either some kind of sleep call in the
function (e.g. every 1 sec as you suggest), or perhaps use a semaphore so that
your code was only woken up when needed.
Although I've not written it yet, this is what I'll probably be doing.
I'm not sure if this is what the 'trigger' callback does in Lighty, because I'm
not familiar with the internal workings of it.
> I think src/event/ngx_event.h has some things that may be useful
> (ngx_add_event, etc).
Thanks. It's on my list of places to investigate the code. :-)
I'll let you know if I work out how to do it.
More information about the nginx