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 BinPath, DbPath and SockPath as command-line arguments after resolving them to absolute paths. The daemon log file is created in RunDir, and the stdout and stderr of the daemon is redirected to the log file.
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 // RunDir is the directory in which to place the daemon log file. RunDir string }
SpawnConfig keeps configurations for spawning the daemon.