daemon

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ProtocolVersion = 1

ProtocolVersion is the current IPC protocol version

Variables

This section is empty.

Functions

func IsDaemonChild added in v2.6.0

func IsDaemonChild() bool

IsDaemonChild returns true if the current process is the daemon child process

func SocketPathForVault added in v2.6.1

func SocketPathForVault(vaultRoot string) (string, error)

SocketPathForVault derives a deterministic Unix domain socket path for the given vault. Unix domain socket paths are limited to 104 bytes on macOS (108 on Linux). To avoid exceeding this limit with long vault paths, we derive a short hash-based path in /tmp that is always well under the limit.

Types

type Daemon

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

Daemon manages the touchlog daemon lifecycle

func NewDaemon

func NewDaemon(vaultRoot string) *Daemon

NewDaemon creates a new daemon instance for a vault

func (*Daemon) GetPID

func (d *Daemon) GetPID() int

GetPID returns the daemon PID from the PID file

func (*Daemon) IsRunning

func (d *Daemon) IsRunning() bool

IsRunning checks if the daemon is running

func (*Daemon) Run added in v2.6.0

func (d *Daemon) Run() error

Run runs the daemon in the foreground (blocking). This is called by the daemon child process after forking. It blocks until the daemon receives a shutdown signal (SIGINT, SIGTERM) or the IPC server is shut down via a Shutdown command.

func (*Daemon) SocketPath added in v2.6.1

func (d *Daemon) SocketPath() string

SocketPath returns the path to the daemon's Unix domain socket

func (*Daemon) Start

func (d *Daemon) Start() error

Start launches the daemon as a background process. It forks a child process that runs the daemon loop via Run(). The parent process returns after confirming the child started successfully.

func (*Daemon) Status

func (d *Daemon) Status() (bool, int, error)

Status returns the daemon status

func (*Daemon) Stop

func (d *Daemon) Stop() error

Stop stops the daemon

func (*Daemon) WritePID

func (d *Daemon) WritePID(pid int) error

WritePID writes the PID to the PID file

type Message

type Message struct {
	Version int             `json:"version"`
	Type    MessageType     `json:"type"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

Message represents an IPC message

func NewMessage

func NewMessage(msgType MessageType, payload interface{}) (*Message, error)

NewMessage creates a new message

type MessageType

type MessageType string

MessageType represents the type of IPC message

const (
	MessageTypeStatus       MessageType = "Status"
	MessageTypeQueryExecute MessageType = "QueryExecute"
	MessageTypeReindexPaths MessageType = "ReindexPaths"
	MessageTypeShutdown     MessageType = "Shutdown"
)

type QueryExecuteRequest

type QueryExecuteRequest struct {
	Query string `json:"query"`
}

QueryExecuteRequest represents a query execution request

type QueryExecuteResponse

type QueryExecuteResponse struct {
	Results interface{} `json:"results"`
}

QueryExecuteResponse represents a query execution response

type ReindexPathsRequest

type ReindexPathsRequest struct {
	Paths []string `json:"paths"`
}

ReindexPathsRequest represents a reindex paths request

type ReindexPathsResponse

type ReindexPathsResponse struct {
	Processed int `json:"processed"`
}

ReindexPathsResponse represents a reindex paths response

type Response

type Response struct {
	Version int         `json:"version"`
	Success bool        `json:"success"`
	Error   string      `json:"error,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

Response represents an IPC response

func NewResponse

func NewResponse(success bool, data interface{}, err error) *Response

NewResponse creates a new response

type Server

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

Server handles IPC communication via Unix domain socket

func NewServer

func NewServer(vaultRoot string, sockPath string, cfg *config.Config) (*Server, error)

NewServer creates a new IPC server. sockPath is the Unix domain socket path for IPC communication. Use SocketPathForVault to derive a safe socket path that respects the macOS 104-byte limit for Unix domain socket paths.

func (*Server) Done added in v2.6.0

func (s *Server) Done() <-chan struct{}

Done returns a channel that's closed when the server is shut down. This allows callers to block until the server exits (e.g., via IPC Shutdown).

func (*Server) SocketPath added in v2.6.1

func (s *Server) SocketPath() string

SocketPath returns the path to the server's Unix domain socket

func (*Server) Start

func (s *Server) Start() error

Start starts the IPC server

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the IPC server

type StatusRequest

type StatusRequest struct{}

StatusRequest represents a status request

type StatusResponse

type StatusResponse struct {
	Running bool `json:"running"`
	PID     int  `json:"pid,omitempty"`
}

StatusResponse represents a status response

Jump to

Keyboard shortcuts

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