Watchman: Execute a command when something changes
31–40 of 98 posts
Re: Watchman: Execute a command when something changes
#32For those use-cases I use entr ( https://github.com/clibs/entr ). In what sense does watchman differ to it? Didn't see anything related to this at first glance :-)
Re: Watchman: Execute a command when something changes
#33I have been using reflex https://github.com/cespare/reflex for the same thing in some of our docker projects
Example .reflex.conf to run one command when an openapi spec changes and another when any go files change:
-g "spec.yaml" -- bash -c 'make'
-sr "\.go$" -- go run cmd/app/main.go
Then run it with: reflex -d fancy -c .reflex.confRe: Watchman: Execute a command when something changes
#34Re: Watchman: Execute a command when something changes
#35I've seen about a dozen versions of this now. So my question is, who watches the watchmen?
If it’s running in a shell, it’d be the terminal session’s shell. If it’s running as a daemon, in a traditional Unix environment, it’d be the init process (pid 0).
Neither init or a shell or any other userspace code. The userspace code like in inotifywait or incron just tells the kernel what it wants the kernel to watch, and then exits, gone, no further parent, not even init.
Ok now that I mentioned incron..., incron being a daemon is managed by init, but incron is not watching any files, not even it's own config files. incron just reads it's incrontab files and registers the desired events with the kernel, and then performs the desired actions when the kernel triggers it. It notices when it's own config files change the same way as any other inotify job, it asks the kernel to tell it when they change.
incron is like cron where you write a crontab-like file that specifies a command of your choosing. Pretty much the same as this thing minus some colorful display.
I guess the point of this thing would be if it provides a consistent wrapper interface over the various fs watching mechanisms on different OS's.
But for linux, I've already been using incron to do this job efficiently for ages.
Re: Watchman: Execute a command when something changes
#36Re: Watchman: Execute a command when something changes
#37Not to be confused with Facebook’s file watch daemon, also names watchman, which does the same sort of thing but is more complicated. There’s a bunch of tools that integrate Facebook’s watchman for more efficient change tracking. Advantages of Facebook’s watchman: 1. Implements efficient file system event watches on macOS and Windows 2. IPC/daemon system reduces resource use because overlapping watches/triggers don’t…
Also not to be confused with watchdog and it's command watchmedo, which is what I thought this was when I first read the headline. I don't know what the differences are, but I use watchdog to restart my local celery workers when I make changes. It's scripted out so I don't ever use the command directly. https://pypi.org/project/watchdog/ https://github.com/gorakhargosh/watchdog EDIT: Now I'm wondering how often I mis…
> The Watchdog Timer in the PIC16F819 The watchdog timer can be a real source of pain and can also make a PIC system incredibly robust and reliable. But what exactly is the watchdog timer? Simply put, the watchdog timer is a hardware timer in the PIC that, if not constantly reset by the software, will cause the PIC to reset. This feature can be incredibly useful if the PIC should hang due to a hardware or software issue and guarantees that the PIC will restart from the beginning. Not only does it reset the system, it also flags a bit that can be used to determine if the system just crashed.
Ref: https://maker.pro/pic/tutorial/how-to-get-started-with-pic-m...
[1]: PIC microcontroller, is a small hardware simliar to arduino but more on a lower level.
Re: Watchman: Execute a command when something changes
#38this project hasn't had a commit in 8 years and only has a handful of stars. It confusingly shares the name with a much more popular tool from Meta—though the use case is slightly different. There are other much more popular tools that do the same thing, like entr, watchexec, and nodemon. Why is this posted?
Re: Watchman: Execute a command when something changes
#39Not to be confused with Facebook’s file watch daemon, also names watchman, which does the same sort of thing but is more complicated. There’s a bunch of tools that integrate Facebook’s watchman for more efficient change tracking. Advantages of Facebook’s watchman: 1. Implements efficient file system event watches on macOS and Windows 2. IPC/daemon system reduces resource use because overlapping watches/triggers don’t…
Re: Watchman: Execute a command when something changes
#40Earlier quoted context omitted.
ifnotifywait doesn't exist on macOS, so in addition to that not being an option on macos, this would be something you could write tools that a team who used multiple platforms, or a person with setups on multiple os's, could use. I suspect this might even be usable on windows. [edit: fswatch looks very promising, and may be a better choice than either ifnotifywait or watchman]
Discovered fswatch recently, it's proved very useful, my favorite use being replacing a few situations where I was using sshfs with fswatch+rsync: no network lag on save/load, can even work offline, but everything still makes its way to the network destination!
test-watch:
make --no-print-directory test || :
fswatch --event Updated -o test/*.c test/*.h src/ | xargs -n1 -I{} make --no-print-directory test