daemon

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func LockPath added in v0.13.0

func LockPath(volDir string) string

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 LogPath

func LogPath(volDir string) string

func PidPath

func PidPath(volDir string) string

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

func Run(folder string, scanInterval, remoteInterval time.Duration) error

Run is the daemon main loop, executed in the foreground of the (usually detached) `bdrive daemon run` process.

func Running

func Running(volDir string) (int, bool)

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.

func Start

func Start(folder, volDir string, scanInterval, remoteInterval time.Duration) (int, error)

Start launches a detached daemon for the folder (no-op if already running).

func Stop

func Stop(volDir string) (bool, error)

Stop terminates the daemon for a mount and waits for it to exit. Exit is observed by the lock being released, not by the pid disappearing: the pid could be recycled while we wait, and the lock cannot.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL