daemon

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

internal/daemon/bind.go

internal/daemon/daemon.go

internal/daemon/lock.go

internal/daemon/pid.go

internal/daemon/rotlog.go

internal/daemon/run.go

Index

Constants

This section is empty.

Variables

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

Functions

func Run

func Run(cfg config.Config) error

func SpawnDetached

func SpawnDetached(selfPath string, extraArgs ...string) error

SpawnDetached starts `selfPath daemon [extraArgs...]` in a detached process so the CLI can exit while the daemon continues running. extraArgs are passed before the "daemon" subcommand so flags like --config propagate correctly.

Types

type Clock

type Clock interface{ Now() time.Time }

type Core

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

func NewCore

func NewCore(cfg config.Config, secret string, hist *history.Store, stopFn func()) *Core

func (*Core) ExpireDue

func (c *Core) ExpireDue(now time.Time)

func (*Core) FindByToken

func (c *Core) FindByToken(tok string) (*share.Share, bool)

func (*Core) IdleFor

func (c *Core) IdleFor(now time.Time) (time.Duration, bool)

func (*Core) Info added in v0.2.0

func (c *Core) Info(query string) (admin.InfoPayload, error)

func (*Core) List

func (c *Core) List() admin.ListResponse

func (*Core) MarkExpired

func (c *Core) MarkExpired(id, reason string)

func (*Core) Reshare

func (c *Core) Reshare(id string) (admin.SharePayload, error)

func (*Core) RestoreFromHistory

func (c *Core) RestoreFromHistory() error

func (*Core) Revoke

func (c *Core) Revoke(id string) error

func (*Core) Secret

func (c *Core) Secret() string

func (*Core) Share

func (c *Core) Share(req admin.ShareRequest) (admin.SharePayload, error)

func (*Core) Status

func (c *Core) Status() admin.StatusResponse

func (*Core) Stop

func (c *Core) Stop()

func (*Core) TouchAdmin

func (c *Core) TouchAdmin()

type Lockfile

type Lockfile interface {
	// Read returns the advisory metadata written into the file.
	Read() (Meta, error)
	// Write atomically replaces the file's content with m and fsyncs.
	Write(m Meta) error
	// Close releases the lock and closes the underlying handle.
	Close() error
}

Lockfile represents the daemon's exclusive lock. The OS releases it on process exit, including crashes.

func AcquireLock

func AcquireLock(path string) (Lockfile, error)

AcquireLock obtains an exclusive lock on path. Returns ErrLocked if another process already holds it.

type Meta

type Meta struct {
	PID       int    `json:"pid"`
	AdminPort int    `json:"admin_port"`
	Secret    string `json:"secret"`
	Version   string `json:"version"`
}

Meta is the advisory content of the lockfile.

func ReadLockfile

func ReadLockfile(path string) (Meta, error)

Jump to

Keyboard shortcuts

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