daemon

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShutdownTimedOut = errors.New("daemon shutdown timed out")

ErrShutdownTimedOut indicates the daemon did not finish shutting down within its grace/force timeout.

Functions

This section is empty.

Types

type Daemon

type Daemon struct {
	Watcher *watch.DropFolderWatcher
	// Optional: if nil, clipboard polling is disabled.
	Poller *clipboard.Poller
	Proc   processor.Processor

	// Optional: if nil, magnets are logged only.
	Tx *transmission.Client

	// Optional: unified operational logger.
	Logger logging.Logger

	// Host used for "Track progress here" line (e.g., "localhost:9091").
	TransmissionHost string

	// Destination directories (resolved absolute paths)
	MoviesDir string
	ShowsDir  string

	// If true, daemon will defer processing until destination
	// directories exist and are writable.
	DeferDestinationChecks bool

	// Sounds (best-effort; empty disables)
	SoundInput string // played on successful Transmission add
	SoundDone  string // played after successful APPLIED processing based on DoneNotificationMode
	// done notification policy: per_file | per_job | off
	DoneNotificationMode string

	// Minimum spacing between done-sound plays. Per-file mode on a fast,
	// same-filesystem batch can trigger many done signals within
	// milliseconds of each other; without coalescing they'd overlap into a
	// cacophony rather than distinct dings. If <= 0, defaults to 3s.
	SoundDoneCooldown time.Duration

	// Time to wait for in-flight processing jobs to finish after shutdown is requested.
	ShutdownGraceDuration time.Duration

	// Additional time to wait after force-canceling in-flight jobs.
	ShutdownForceTimeout time.Duration

	// Transmission add timeout
	MagnetTimeout time.Duration

	// If true, after any successful APPLIED processing, attempt to remove all completed torrents from Transmission.
	AutoCleanupCompletedTorrents bool

	// Cooldown between Transmission cleanup attempts. If <= 0, defaults to 120s.
	CleanupCooldown time.Duration
	// contains filtered or unexported fields
}

Daemon wires together the watcher + clipboard poller + processor + optional Transmission client.

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context) error

Run starts the daemon loop. The caller is responsible for creating and starting the Watcher and Poller. However, for convenience and symmetry with the current approach, Run() will Start() them if not started yet.

Recommended usage from main:

w := watch.NewDropFolderWatcher(...)
p := clipboard.NewPoller(...)
d := &daemon.Daemon{Watcher:w, Poller:p, Proc:proc, Tx:tx, ...}
return d.Run(ctx)

Jump to

Keyboard shortcuts

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