Documentation ¶
Overview ¶
Package daemon provides the entry point of the daemon sub-program and helpers to spawn a daemon process.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Daemon ¶
type Daemon struct { // BinPath is the path to the Elvish binary itself, used when forking. This // field is optional only when spawning the daemon. 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 }
Daemon keeps configurations for the daemon sub-program. It can be used both from the main function for running the daemon and from another process (typically the first Elvish shell session) for spawning a daemon.
func (*Daemon) Main ¶
Main is the entry point of the daemon sub-program. It simply sets the umask (if relevant) and runs serve. It always return a nil error, since any errors encountered is logged in the serve function.
func (*Daemon) Spawn ¶
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.