You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@trafficserver.apache.org by Mo Chen <un...@gmail.com> on 2022/07/14 17:00:32 UTC

Proposal to Add a File Change Monitoring API to ATS

Hi all,

The following is a proposal of a new plugin API for file change
notification.

/** Register to be called back when a file is changed.
  *
  * filename can be a path to an existing file, or an existing directory.
  * kind one of TS_WATCH_CREATE, TS_WATCH_DELETE, TS_WATCH_MODIFY
  * the function returns a watch descriptor, which can be used to identify
the watch,
  *   or unregister it.
  *
  * The edata (a.k.a. cookie) field of the continuation handler will
contain information
  * depending on the type of file event.  edata is always a pointer to a
TSFileWatchData.
  * If the event is TS_EVENT_FILE_CREATED, name is a pointer to a
null-terminated string
  * containing the file name.  Otherwise, name is a nullptr.  wd is the
watch descriptor
  * for the event. */
tsapi TSWatchDescriptor TSFileEventRegister(const char *filename,
TSFileWatchKind kind, TSCont contp);

/** Unregister a watch
  *
  * wd is a descriptor returned from TSFileEventRegister
  */
tsapi void TSFileEventUnRegister(TSWatchDescriptor wd);

The reasons for introducing these are to give plugins a way to update their
configuration
without triggering a reload, and to let plugins such as statichit or
healthcheck reload their
input files intelligently.

The proposed implementation is to use inotify in Linux, and kqueue in
FreeBSD.  This is the draft
PR of the work in progress:
https://github.com/apache/trafficserver/pull/8960.

-Mo