Debian Codegraph @

README

raw
1 NAME
2 App::Inotify::Hookable - blocking command-line interface to inotify
3
4 SYNOPSIS
5 Watch a directory, tell us when things change in it:
6
7 inotify-hookable --watch-directories /tmp/watch-this
8
9 Watch a git tree, some configs, and a repository of static assets,
10 restart the webserver or compress those assets if anything changes:
11
12 inotify-hookable \
13 --watch-directories /etc/uwsgi \
14 --watch-directories /git_tree/central \
15 --watch-directories /etc/app-config \
16 --watch-directories /git_tree/static_assets \
17 --on-modify-path-command "^(/etc/uwsgi|/git_tree/central|/etc/app-config)=sudo /etc/init.d/uwsgi restart" \
18 --on-modify-path-command "^/git_tree/static_assets=(cd /git_tree/static_assets && compress_static_assets)"
19
20 Or watch specific files:
21
22 inotify-hookable \
23 --watch-files /var/www/cgi-bin/mod_perl_handler \
24 --on-modify-command "apachectl restart"
25
26 DESCRIPTION
27 This simple command-line program is my replacement for the functionality
28 offered by Plack's Filesys::Notify::Simple. I found that on very large
29 git trees Plack would spend an inordinate amount watching the filesystem
30 for changes.
31
32 This program uses Linux::Inotify2, so the kernel will notify it
33 instantly when something changes (actually it's so fast that we have to
34 work around how fast it sends us events).
35
36 The result is that you can run this e.g. in a screen session and have it
37 watch your development environment, and your webserver will have begun
38 restarting before your finger leaves the *save* button.
39
40 vim and emacs temporary files are ignored by default (see
41 "--ignore-paths".) so you can edit your files without your server
42 restarting unnecessarily.
43
44 Currently the command-line interface for this is the only one that
45 really makes sense, this module is entirely blocking (although it could
46 probably run in another process via POE or something). Patches welcome.
47
48 OPTIONS
49 Note that boolean options can be negated with "--no-OPTION", e.g.
50 "--no-r" or "--no-recursive" to turn off the "--recursive" option which
51 is on by default.
52
53 "-w" or "--watch-directories"
54 Specify this to watch a directory, you can give this however many times
55 you like to watch lots of directories.
56
57 "-f" or "--watch-files"
58 Watch a file, specify multiple times for multiple files. You can watch
59 files and directories in the same command.
60
61 "-r" or "--recursive"
62 If you supply this any directory you give will be recursively watched.
63 This is on by default.
64
65 "-c" or "--on-modify-command"
66 A command that will be run when something is modified.
67
68 "-C" or "--on-modify-path-command"
69 A key-value pair where the key is a regex that'll be matched against a
70 modified path, and the value is a command that'll be run. See the
71 "SYNOPSIS" for an example.
72
73 Useful for e.g. restarting a webserver if you modify directory A but
74 compressing some static assets if you modify directory B.
75
76 "-t" or "--buffer-time"
77 Linux will send you inotify events really fast, so fast that if you run
78 something like:
79
80 touch foo bar
81
82 You might get an event for foo in one batch, followed by an event for
83 bar later on.
84
85 To deal with this we enter a loop when we start getting events and sleep
86 for a default of 100 microseconds, as long as we keep getting events we
87 keep sleeping for 100 microseconds, but as soon as we haven't received
88 anything new we fire off our event handlers.
89
90 "-i" or "--ignore-paths"
91 Regexes for files/directories to ignore events for. By default this is
92 set to regexes for vim and emacs temporary files, "qr{\..*sw.\z}" and
93 "qr{\.\#[^/]+\z}" respectively.
94
95 The regexes match after any "/" in the path or the beginning of the
96 string.
97
98 "-d" or "--debug"
99 Spew out some verbose debug output while running.
100
101 ACKNOWLEDGMENT
102 This module was originally developed at and for Booking.com. With
103 approval from Booking.com, this module was generalized and put on CPAN,
104 for which the authors would like to express their gratitude.
105
106 AUTHOR
107 Ævar Arnfjörð Bjarmason <[email protected]>
108