HOOKABLE(1p)
π HOOKABLE(1p) β inotify-hookable, bestie edition π
okay so. this is the manual page for inotify-hookable, which lives in the HOOKABLE(1p) section of your man pages, and it is a blocking command-line interface to inotify. yes it's giving very specific. yes you're gonna love it. let's go π¦
β¨ NAME β¨
inotify-hookable β blocking command-line interface to inotify
πΈ SYNOPSIS πΈ
Watch a directory, tell us when things change in it:
inotify-hookable --watch-directories /tmp/watch-this
Watch a git tree, some configs, and a repository of static assets, restart the webserver or compress those assets if anything changes:
inotify-hookable \
--watch-directories /etc/uwsgi \
--watch-directories /git_tree/central \
--watch-directories /etc/app-config \
--watch-directories /git_tree/static_assets \
--on-modify-path-command "^(/etc/uwsgi|/git_tree/central|/etc/app-config)=sudo /etc/init.d/uwsgi restart" \
--on-modify-path-command "^/git_tree/static_assets=(cd /git_tree/static_assets && compress_static_assets)"
Or watch specific files:
inotify-hookable \
--watch-files /var/www/cgi-bin/mod_perl_handler \
--on-modify-command "apachectl restart"
like. that's it. that's the whole vibe. π
π DESCRIPTION π
So this simple command-line program is the author's replacement for the functionality offered by Plack's Filesys::Notify::Simple. plot twist: on very large git trees, Plack would spend an inordinate amount of time watching the filesystem for changes. not cute. not slay.
This program uses Linux::Inotify2, so the kernel will notify it instantly when something changes. (ngl it's actually so fast that we have to work around how fast it sends us events. the kernel is doing too much fr fr π)
The result? You can run this e.g. in a screen session and have it watch your development environment, and your webserver will have begun restarting before your finger leaves the save button. main character energy honestly π
vim and emacs temporary files are ignored by default (see --ignore-paths), so you can edit your files without your server restarting unnecessarily. periodt. π
Currently the command-line interface for this is the only one that really makes sense β this module is entirely blocking (although it could probably run in another process via POE or something). Patches welcome. π«Ά
π OPTIONS π
okay bestie, quick note before we dive in: boolean options can be negated with --no-OPTION, e.g. --no-r or --no-recursive to turn off the --recursive option, which is on by default. yes ma'am. π
-w or --watch-directories
Specify this to watch a directory. You can give this however many times you like to watch lots of directories. spam it, queen. π¦
-f or --watch-files
Watch a file β specify multiple times for multiple files. You can watch files and directories in the same command. mix and match, we love a flexible icon. β¨
-r or --recursive
If you supply this, any directory you give will be recursively watched. This is on by default. (so like, remember the --no-recursive thing from up top if you're not feeling it π
)
-c or --on-modify-command
A command that will be run when something is modified. π₯
-C or --on-modify-path-command
A key-value pair where the key is a regex that'll be matched against a modified path, and the value is a command that'll be run. See the SYNOPSIS for an example.
Useful for e.g. restarting a webserver if you modify directory A, but compressing some static assets if you modify directory B. different path, different choreography. π
-t or --buffer-time
Linux will send you inotify events really fast β so fast that if you run something like:
touch foo bar
You might get an event for foo in one batch, followed by an event for bar later on. messy. π΅βπ«
To deal with this we enter a loop when we start getting events and sleep for a default of 100 microseconds. As long as we keep getting events we keep sleeping for 100 microseconds, but as soon as we haven't received anything new we fire off our event handlers. it's giving patience. it's giving eventually. π§
-i or --ignore-paths
Regexes for files/directories to ignore events for. By default this is set to regexes for vim and emacs temporary files: qr{\..*sw.\z} and qr{\.\#[^/]+\z} respectively.
The regexes match after any / in the path or the beginning of the string. π―
-d or --debug
Spew out some verbose debug output while running. not me reading the logs like a novel π
-q or --[no-]quiet
Don't log noisy information. shhh. π€«
π ACKNOWLEDGMENT π
This module was originally developed at and for Booking.com. With approval from Booking.com, this module was generalized and put on CPAN, for which the authors would like to express their gratitude. iconic behaviour, honestly. π
π AUTHOR π
Γvar ArnfjΓΆrΓ° Bjarmason <avar@cpan.org>
okay that's the whole page bestie, go forth and watch some directories π and a lil sign-off for the record books: this page is perl v5.32.1, dated 2021-03-07, and yes it's the HOOKABLE(1p) one. slay, bye πβ¨
π¦ where this page comes from
- debian bookworm: inotify-hookable 0.09-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: inotify-hookable 0.09-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: inotify-hookable 0.09-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: inotify-hookable 0.09-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms