Documentation ¶
Overview ¶
Package daemon implements a service for mediating access to the data store, and its client.
Most RPCs exposed by the service correspond to the methods of Store in the store package and are not documented here.
Index ¶
Constants ¶
const Version = -93
Version is the API version. It should be bumped any time the API changes.
Variables ¶
var ( // ErrDaemonUnreachable is returned when the daemon cannot be reached after // several retries. ErrDaemonUnreachable = errors.New("daemon offline") )
var Program prog.Program = program{}
Program is the daemon subprogram.
Functions ¶
func Serve ¶
func Serve(sockpath, dbpath string)
Serve runs the daemon service, listening on the socket specified by sockpath and serving data from dbpath. It quits upon receiving SIGTERM, SIGINT or when all active clients have disconnected.
func Spawn ¶ added in v0.14.0
func Spawn(cfg *SpawnConfig) error
Spawn spawns a daemon process in the background by invoking BinPath, passing DbPath, SockPath and LogPathPrefix as command-line arguments after resolving them to absolute paths. A suitable ProcAttr is chosen depending on the OS and makes sure that the daemon is detached from the current terminal (so that it is not affected by I/O or signals in the current terminal), and keeps running after the current process quits.
Types ¶
type Client ¶
type Client interface { store.Store ResetConn() error Close() error Pid() (int, error) SockPath() string Version() (int, error) }
Client represents a daemon client.
type SpawnConfig ¶ added in v0.14.0
type SpawnConfig struct { // BinPath is the path to the Elvish binary itself, used when forking. This // field is used only when spawning the daemon. If empty, it is // automatically determined with os.Executable. BinPath string // DbPath is the path to the database. DbPath string // SockPath is the path to the socket on which the daemon will serve // requests. SockPath string // LogPathPrefix is used to derive the name of the log file by adding the // pid. LogPathPrefix string }
SpawnConfig keeps configurations for spawning the daemon.