Skip to content

Implement auto-watching logfiles

It would be nice if logfiles were automagically watched and nginx reloaded each time logfiles are rotated. That's considerably more difficult than same for certificate files and config files, since:

  1. logfiles are constantly being modified (obviously);
  2. inotify is not able to watch for a file being moved other than by watching the parent directory for moved_from events.

Implementing this would require a separate watch function that would figure out parent directories of logfiles and set up moved_from watches on them, and then filter the results for events that only affect logfiles in question. This would also require having a way to run 2 separate inotifywait processes (or functions based on them) and restarting both when either exits.

Edited by Michał Woźniak