xeno
xeno copied to clipboard
add new xeno fswatch command
This PR implements a new xeno fswatch
command which uses the fswatch
file-change notification utility to optimize (ie: near realtime) local change detection and initiating syncs to the remote hosts.
https://github.com/emcrisostomo/fswatch
I wanted a way to more quickly sync changes from my local workstation to remote machines. The best I had come up with was to run xeno daemon
with a low (3-5 second) interval time, but this is not optimal when you have several repos and generates a lot of traffic and log messages due to the frequent ssh'ing. I wanted something faster to get close as possible to near-realtime detection of changes and sync'ing to the remote host. fswatch
which is cross platform (osx, linux, *bsd) seemed like a perfect fit.
Usage is very similar to xeno daemon
: xeno fswatch
to start the xeno-fswatch daemon and xeno fswatch --stop
to stop it. When a change is detected in any of the repos in $HOME/.xeno/local/*
a corresponding xeno sync SESSION_ID
will be triggered.
I still use xeno daemon
to periodically pull in remote changes but I now use it with a much longer interval (120 seconds or more) and rely on xeno fswatch
to handle most sync'ing.
I considered implementing this within the xeno daemon
command and that may still be the best place for this, but keeping it separate made initial implementation and testing easier.
Any thoughts on accepting this into xeno mainline? I'd be willing to try to adapt it to fit the overall vision of xeno. Let me know.
Apologies for bumping version number. I did that to make it easier to figure out which of my own hosts I had updated.
This looks awesome, I was really hoping to implement something like this at some point. Do you mind giving me a few days to review? I just submitted my d.phil thesis today, so I'm a bit braindead, but I'd like to have a look later this week. Would very much like to have this in the main line.
Sure, sounds good. It will give me some time to test it with my own workflow too =)
On Mon, Feb 16, 2015 at 2:54 PM, Jacob Howard [email protected] wrote:
This looks awesome, I was really hoping to implement something like this at some point. Do you mind giving me a few days to review? I just submitted my d.phil thesis today, so I'm a bit braindead, but I'd like to have a look later this week. Would very much like to have this in the main line.
— Reply to this email directly or view it on GitHub https://github.com/havoc-io/xeno/pull/21#issuecomment-74585208.
Some notes from a day of using this across two machines:
- implementing the batch mode mentioned in the @TODO is probably a good idea. There is a case where a xeno-daemon's full sync can also trigger fswatch. This was particularly noticable when I came to work and installed the new version with fswatch support and also started up xeno-daemon. xeno-daemon pulled down many files that had changed while working over the weekend on another host. This could be mitigated by batching up changes and only calling sync once-per-repo rather than once-per-file-changed.
- It appears that fswatch (at least on osx with FSEvents facility) does not pick up new directories when a new session is added. Workaround is to stop/restart xeno-fswatch.