Repository navigation
Description
Hello,
I'm trying to use watchman to execute a Makefile target whenever a file changes. However, for this example I'm just trying to get it to do anything at all!
I've set up some roots:
[rdio/rdio] watchman watch-list
{
"version": "2.9.3",
"roots": [
"/Users/justin/Dev/rdio/rdio/web/client/Components",
"/Users/justin/Dev/rdio/rdio/web/client/core"
]
}
I've set up some triggers:
[rdio/rdio] watchman trigger-list `pwd`/web/client/Components
{
"version": "2.9.3",
"triggers": [
{
"name": "component-bits",
"command": [
"ls",
"-l"
],
"rules": [
{
"pattern": "*.js *.less *.html",
"include": true,
"negated": false
}
]
}
]
}
And I'm running a command to log things: watchman --persistent --server-encoding=json log-level debug
When I modify a js file, it sees the modification but never executes anything. The relevant bits of the log file are:
{
"version": "2.9.3",
"log": "1389754641: tid=85434368 fse_thread: add /Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton/PlayButton.js 15400\n"
}
{
"version": "2.9.3",
"log": "1389754641: tid=84897792 add_pending: /Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton/PlayButton.js\n"
}
{
"version": "2.9.3",
"log": "1389754641: tid=84897792 lstat(/Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton/PlayButton.js) file=0x7f8a327a2890 dir=0x0\n"
}
{
"version": "2.9.3",
"log": "1389754641: tid=84897792 file changed exists=1 via_notify=1 stat-changed=0 isdir=0 /Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton/PlayButton.js\n"
}
{
"version": "2.9.3",
"log": "1389754641: tid=84897792 lstat(/Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton) file=0x7f8a32715330 dir=0x7f8a32703b00\n"
}
{
"version": "2.9.3",
"log": "1389754641: tid=84897792 file changed exists=1 via_notify=1 stat-changed=0 isdir=1 /Users/justin/Dev/rdio/rdio/web/client/Components/PlayButton\n"
}
{
"version": "2.9.3",
"log": "1389754641: tid=88330240 notify_thread[/Users/justin/Dev/rdio/rdio/web/client/core] assessing triggers\n"
}
{
"version": "2.9.3",
"log": "1389754641: tid=84897792 sub last=2 pending=3\n"
}
{
"version": "2.9.3",
"log": "1389754641: tid=88330240 notify_thread[/Users/justin/Dev/rdio/rdio/web/client/core] assessing triggers\n"
}
{
"version": "2.9.3",
"log": "1389754641: tid=84897792 notify_thread[/Users/justin/Dev/rdio/rdio/web/client/Components] assessing triggers\n"
}
After that it just continues to print lines about assessing triggers.
It appears from the source that I should eventually see some logs about processing events and the posix_spawnp line with the return code of the command. None of that seems to be happening.
Where should I start debugging this? I'm more than willing to dive into the code but I don't yet understand how the FSEvent watcher goes from adding something to the pending queue to actually spawning the appropriate processes.
Any help would be much appreciated!
Activity
wez commentedon Jan 15, 2014
Hi Justin,
The pattern in your rules looks off; I'd expect to see one rule entry for each of the patterns ".js", ".less", "*.html"
I suspect that you quoted the patterns all together like this:
'*.js *.less *.html'instead of passing them like this:'*.js' '*.less' '*.html'when you ran watchman to set up your watch.You should be able to remove the current watch using the watch-del sub command and then re-adding it with the appropriate quoting.
Hopefully smooth sailing from here on out :-)
wez commentedon Jan 15, 2014
sorry, trigger-del, not watch-del (these responses drafted quickly without RTFM'ing ;-)
JustinTulloss commentedon Jan 15, 2014
Awesome! That works much better. I should have asked earlier instead of going straight to the source.
Is there a way to see the output of the command that gets triggered?
Thanks for your help!
wez commentedon Jan 15, 2014
The output will go to the watchman log; if you want it to go somewhere else, the current recommendation is to use a wrapper script that redirects its output and runs the actual command:
Then register the wrapper script as your trigger.
I've opened #21 to track making this sort of thing easier, but have no immediate plans to add it right now
JustinTulloss commentedon Jan 16, 2014
If watchman was running in the foreground, would there be a way to get those logs there? I'm trying to make output of failed build steps obvious.
wez commentedon Apr 1, 2014
Sorry, this dropped off my radar because the issue is closed; I'll answer your question in #32 which is a similar problem
change logging in exit handlers to not avoid locking