daemon

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PIDFileName   = "mycelicmemory.pid"
	StateFileName = "mycelicmemory.state"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Daemon

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

Daemon manages the mycelicmemory daemon lifecycle

func New

func New(configDir, version string) *Daemon

New creates a new Daemon instance

func (*Daemon) Cleanup

func (d *Daemon) Cleanup()

Cleanup removes PID and state files (called on graceful shutdown)

func (*Daemon) Daemonize

func (d *Daemon) Daemonize(args []string) (bool, error)

Daemonize forks the current process and runs it as a daemon Returns true if we're in the child (daemon) process, false if parent

func (*Daemon) IsRunning

func (d *Daemon) IsRunning() bool

IsRunning checks if the daemon is currently running

func (*Daemon) KillAll

func (d *Daemon) KillAll() (int, error)

KillAll kills all mycelicmemory processes

func (*Daemon) ListProcesses

func (d *Daemon) ListProcesses() ([]ProcessInfo, error)

ListProcesses returns a list of running mycelicmemory processes

func (*Daemon) PIDPath

func (d *Daemon) PIDPath() string

PIDPath returns the path to the PID file

func (*Daemon) ReadPID

func (d *Daemon) ReadPID() (int, error)

ReadPID reads the PID from the PID file

func (*Daemon) ReadState

func (d *Daemon) ReadState() (*State, error)

ReadState reads the daemon state from disk

func (*Daemon) RemovePID

func (d *Daemon) RemovePID() error

RemovePID removes the PID file

func (*Daemon) RemoveState

func (d *Daemon) RemoveState() error

RemoveState removes the state file

func (*Daemon) Start

func (d *Daemon) Start(restEnabled bool, restHost string, restPort int, mcpEnabled bool) error

Start starts the daemon (saves state, writes PID)

func (*Daemon) StatePath

func (d *Daemon) StatePath() string

StatePath returns the path to the state file

func (*Daemon) Status

func (d *Daemon) Status() *Status

Status returns the current daemon status

func (*Daemon) Stop

func (d *Daemon) Stop() error

Stop stops the daemon by sending SIGTERM

func (*Daemon) WritePID

func (d *Daemon) WritePID() error

WritePID writes the current process PID to the PID file

func (*Daemon) WriteState

func (d *Daemon) WriteState(state *State) error

WriteState writes the daemon state to disk

type ProcessInfo

type ProcessInfo struct {
	PID     int           `json:"pid"`
	Type    string        `json:"type"`
	Uptime  time.Duration `json:"uptime"`
	Version string        `json:"version"`
}

ProcessInfo represents information about a running process

type State

type State struct {
	PID         int       `json:"pid"`
	StartTime   time.Time `json:"start_time"`
	Version     string    `json:"version"`
	RESTEnabled bool      `json:"rest_enabled"`
	RESTHost    string    `json:"rest_host"`
	RESTPort    int       `json:"rest_port"`
	MCPEnabled  bool      `json:"mcp_enabled"`
}

State represents the daemon state persisted to disk

type Status

type Status struct {
	Running     bool          `json:"running"`
	PID         int           `json:"pid,omitempty"`
	Uptime      time.Duration `json:"uptime,omitempty"`
	Version     string        `json:"version,omitempty"`
	RESTEnabled bool          `json:"rest_enabled,omitempty"`
	RESTHost    string        `json:"rest_host,omitempty"`
	RESTPort    int           `json:"rest_port,omitempty"`
	MCPEnabled  bool          `json:"mcp_enabled,omitempty"`
}

Status represents the current daemon status

Jump to

Keyboard shortcuts

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