Have you tried using tools like inotify, nodemon or webpack inside Docker or VirtualBox but just couldn't get it to work? The problem lies with the virtual file system. They simply do not support the file notification API. The only existing solution out there is to use a polling method. One such program is fswatch. But it becomes slow once the number of files become big.
xnotify solves all these problems easily while adding some awesome features for common use case.
It works by sending file events from your host machine to your virtual machine over HTTP.
It works on all popular platforms like Windows, Linux and OSX with a single binary.
In addition to that, you can easily run commands on file change using the
Here's a real world example of how I automatically run my Go test and reload the server automatically within VirtualBox:
PowerShell script on my windows host: .\xnotify.exe --verbose --client :8001 -i . -e "(vendor|\.git)$"
The command above watches all files in the current directory, excluding "vendor" and ".git" folders, and sends the event to localhost:8001, the address where our next program is listening on.
Bash script on my Linux VM to automatically run tests: ./xnotify --verbose --listen "0.0.0.0:8001" --base /my/project/dir --batch 50 -- go test -c app/test -- ./test.test -test.failfast
This will listen on 0.0.0.0:8001 for file events that the Windows program is sending. Then it runs the commands after the
-- option, using the working directory of
Bash script on my Linux VM to automatically run reload the server: ./xnotify --verbose --trigger --listen "0.0.0.0:8001" --base /my/project/dir --batch 50 -- go build cmd/main.go -- ./main
This works in the same way, except that the commands after
-- is used to run the web server instead of the tests.
For more examples, see the README at the project page.