daemon

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package daemon holds the background agent's plumbing: a single-instance lock and OS service integration (launchd on macOS, systemd on Linux).

Index

Constants

This section is empty.

Variables

View Source
var ErrRunning = errors.New("daemon already running")

ErrRunning means another daemon already holds the lock.

View Source
var ErrUnsupported = errors.New("automatic start isn't supported on this OS yet — run `sme daemon` yourself")

ErrUnsupported is returned on platforms without service integration yet.

Functions

func Running

func Running() (bool, int)

Running reports whether a daemon holds the lock, and its pid.

Types

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

Lock is held for the daemon's lifetime; the OS releases it if we crash.

func Acquire

func Acquire() (*Lock, error)

Acquire takes the single-instance lock and records our pid.

func (*Lock) Release

func (l *Lock) Release()

Release drops the lock.

type Service

type Service struct {
	OS      string // darwin | linux
	Exe     string // absolute path to the sme binary
	Home    string // SYNCMYENV_HOME
	LogPath string
	Path    string // where the unit/plist file goes
}

Service describes how the daemon is installed on this machine.

func NewService

func NewService() (*Service, error)

NewService resolves paths for the current OS and binary.

func (*Service) Install

func (s *Service) Install() error

Install writes the service file and starts it. Re-installing replaces it.

func (*Service) Installed

func (s *Service) Installed() bool

Installed reports whether the service file exists.

func (*Service) Render

func (s *Service) Render() (string, error)

Render returns the plist (macOS) or unit file (Linux) contents.

func (*Service) Uninstall

func (s *Service) Uninstall() error

Uninstall stops the service and removes its file.

Jump to

Keyboard shortcuts

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