elvish: github.com/elves/elvish/pkg/program/daemon Index | Files

package daemon

import "github.com/elves/elvish/pkg/program/daemon"

Package daemon provides the entry point of the daemon sub-program and helpers to spawn a daemon process.


Package Files

daemon.go sys_unix.go

type Daemon Uses

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 Uses

func (d *Daemon) Main(serve func(string, string)) error

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 Uses

func (d *Daemon) Spawn() 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.

Package daemon imports 6 packages (graph) and is imported by 3 packages. Updated 2019-12-23. Refresh now. Tools for package owners.