stephenh / mirror

A tool for real-time, two-way sync for remote (e.g. desktop/laptop) development
Apache License 2.0
391 stars 37 forks source link

Output per-file status info to systemd/syslog #64

Open mpellegrin opened 3 years ago

mpellegrin commented 3 years ago

Hello,

Is there a way to query, with a pipe, an event, or a status file that would indicate if there are file being synchronized, how many, and eventually which one ?

Having an error log would also be pretty convenient to monitor failures.

I run the program with Systemd, so there may be a way to activate the debug mode, but I do not want to flood my syslog, and I would like precise insight on what the program is actually doing in real-time.

I could also write part of a patch myself, but it has been a long time since I didn't wrote a Java program, do you have any hint on how to achieve such functionality (in which class the file queue is handled, for instance) ?

stephenh commented 3 years ago

indicate if there are file being synchronized, how many, and eventually which one

Well, file paths are output to stdout as they are sent/received:

2020-09-03 09:12:07 INFO  Sending ...file path...

Granted, you don't have any insight into queued paths with that.

The mirror client commands accepts --debug-all and --debug-prefixes commands that will output more debug-ish-level information to stdout that might be the insight you're looking for. But it's still just written to stdout.

Otherwise, no, there is not like a debug/query API that allows interactive/programmatic interrogation of the current state of things.

Having an error log would also be pretty convenient to monitor failures.

It's been long enough that I forgot if errors are written to stdout or stderr, so you could check on that, but in theory that I think stdout/stderr are generally the unix-y way of doing what you're trying to do?

If you really want to start poking at internals, this would be a good starting place of "every so often, look at the queues and see what is going on":

https://github.com/stephenh/mirror/blob/master/src/main/java/mirror/QueueWatcher.java

Currently it only outputs information if it detects queues not draining fast enough, but you could tweak that.