Watchman keeps an eye on changed files
Developer Wez Furlong introduced the open source tool Watchman in a post in the Facebook Engineering group. The tool, licensed under the APL 2.0 licence, monitors files to see if they have changed. It can also trigger actions like automatic builds or send notifications if certain files are changed.
Furlong writes that the development goal was to speed up the build process inside the company; a project like Facebook requires a long series of build steps to go from PHP code to a working application, and those steps were taking too long. To speed things up, the developers decided to start building incrementally, compiling only code that had changed.
The developers were also looking for a tool for other projects that could query and return filesystem changes, but the tools they found that already incorporated this function weren't quite what they wanted, so they took matters into their own hands with Watchman. The tool can be run from the command line or with a JSON protocol and can monitor one or more directory trees, with each tree referred to as a root and watched recursively.
Information about the monitored roots can be extracted with two kinds of syntax, "file queries" and "legacy patterns", with the latter option better suited to quick command line queries. File queries, on the other hand, are better when working with other tools, since they are more "structured and expressive". Commands like trigger can be used to start certain actions if files are changed in accordance with a previously determined pattern.
The tool does still have some weak points – symlinks aren't supported, and even Furlong warns against thinking of it as a silver bullet for fast builds – but he says that there have been noticeable improvements in Facebook internal projects in terms of speed. Watchman runs on Linux, Mac OS X, FreeBSD and Solaris. The code is available on GitHub.
(fab)