Documentation
¶
Overview ¶
Package daemon runs the per-mount background sync loop and manages its lifecycle (detached start, pidfile, graceful stop).
The loop scans the working folder every scan-interval (cheap: size+mtime against the state cache) and talks to the remote every remote-interval — or immediately after local changes, so edits propagate quickly without hammering the object store.
Index ¶
- func LockPath(volDir string) string
- func LogPath(volDir string) string
- func PidPath(volDir string) string
- func Run(folder string, scanInterval, remoteInterval time.Duration) error
- func Running(volDir string) (int, bool)
- func Start(folder, volDir string, scanInterval, remoteInterval time.Duration) (int, error)
- func Stop(volDir string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LockPath ¶ added in v0.13.0
LockPath is the file a live daemon holds an exclusive flock on for its whole lifetime. Liveness is the LOCK, not the pidfile: the kernel drops a flock when the holder dies — including at reboot, and including a crash — so a leftover daemon.pid can never be mistaken for a running daemon.
The pid alone cannot answer this. `kill(pid, 0)` only asks "does some process own this number", and daemon.pid outlives the process (it sits in ~/.bdrive, which survives reboots). Any same-user process that later recycles the pid used to read as a live daemon — which made `bdrive status` lie and, worse, made Start() a silent no-op, so the one documented recovery (`bdrive init`) left the folder unsynced.
func PidPath ¶
The volume store is keyed by the mount id, so exactly one daemon runs per mount and its pid/log live in the store dir.
func Run ¶
Run is the daemon main loop, executed in the foreground of the (usually detached) `bdrive daemon run` process.
func Running ¶
Running reports the daemon pid for a mount if one is alive. The pid is informational (for display and for Stop's signal); aliveness comes from LockPath — see the comment there.
Types ¶
This section is empty.