monitor file
胡聪 (hucc)
hucong.c at foxmail.com
Fri Oct 27 05:19:37 UTC 2017
hello,
On Friday, Oct 27, 2017 12:25 PM, Dk Jack wrote:
>On Thu, Oct 26, 2017 at 9:12 PM, 胡聪 (hucc) <hucong.c at foxmail.com> wrote:
>
>>On Friday, Oct 27, 2017 5:04 AM, Dk Jack wrote:
>>
>>>In my module I'd like to monitor the creation of a file (at a specific) using
>>>inotify or something similar and load some data from the file. How would I go
>>>about hooking up the inotifyFd with the nginx event system so that I get a
>>>callback when the file is created on the disk?
>>
>>
>>First of all, please make sure that this module is behind ngx_event_core_module.
>>Here, we asume the module type is NGX_HTTP_MODULE.
>>
>>Secondly, get some configuration information.
>>
>>Thirdly, module.init_process needs to be implemented. And here are
>>the outline of init_process:
>>if (ngx_worker == 0) {
>> fd = inotify_init1(flags);
>> wd = inotify_add_watch(fd, pathname, mask);
>> c = ngx_get_connection(fd, log);
>> rev = c->read;
>> ...;
>> rev->handler = your_main_callback_handler; /* What you want to do */
>> ngx_add_event(rev, NGX_READ_EVENT, 0);
>>}
>>
>>Hope this helps!
>
>.... This is exactly what I need. Yes, it is a NGX_HTTP_MODULE.
>How do I ensure, "this module is behind ngx_event_core_module"? Thanks.
If the type is NGX_HTTP_MODULE, then the module is already behind
ngx_event_core_module.
More information about the nginx-devel
mailing list