Re:Watchman: Faster builds with large source trees
by _mpu on Thursday May 30, 2013 @05:40PM
(#5795427)
Not sure how inotify is different from while+stat?
[ Parent
| on HN ]
Re:Watchman: Faster builds with large source trees
by yid on Thursday May 30, 2013 @05:44PM
(#5795453)
Your snark is unwarranted. While+stat in a loop is a poll loop in userspace, inotify is a push mechanism in kernel space.
My point was that the additional functionality of this significantly-sized package beyond running inotify+md5+make in a shell script was unclear.
Re:Watchman: Faster builds with large source trees
by Terretta on Thursday May 30, 2013 @06:23PM
(#5795646)
Trivial example use of inotify (or rather, inotifywait) to restart Apache after you edit the Apache conf file or add/edit/remove a site config:
while inotifywait -e attrib,modify /etc/httpd/conf/httpd.conf -e attrib,modify,create,delete,move -r /etc/httpd/sites-enabled ; do
/sbin/service httpd graceful && echo "`date -u --rfc-3339=seconds` httpd graceful" >> /etc/httpd/conf/httpd-conf.log
done
Shows how to monitor a single file and a directory, and do a sequence of commands if events happen. Unlike while stat, this doesn't spam checking the file system for changes, it waits until the kernel notifies that a change happened.To "daemonize" this, tack on an invocation test, perhaps:
#!/bin/bash
if [ "x$1" != "x--" ]; then
$0 -- 1> /etc/httpd/conf/watchconf.log 2> /etc/httpd/conf/watchconf-err.log &
exit 0
fi
while inotifywait -e attrib,modify /etc/httpd/conf/httpd.conf -e attrib,modify,create,delete,move -r /etc/httpd/sites-enabled ; do
/sbin/service httpd graceful && echo "`date -u --rfc-3339=seconds` httpd graceful" >> /etc/httpd/conf/httpd-conf.log
done