monitor file

Dk Jack dnj0496 at gmail.com
Fri Oct 27 04:25:01 UTC 2017


Thanks for the quick response. 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.

Dk


On Thu, Oct 26, 2017 at 9:12 PM, 胡聪 (hucc) <hucong.c at foxmail.com> wrote:

> Hi,
>
> 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!
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20171026/b8ce9335/attachment-0001.html>


More information about the nginx-devel mailing list