daemon

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: GPL-3.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccessDenied  = errors.New("access denied")
	ErrRestartSocket = fmt.Errorf("daemon stop requested to wait for socket activation")

	LookupUserId = user.LookupId
)

Functions

This section is empty.

Types

type Action

type Action struct {
	Script string `json:"script"`
}

type Command

type Command struct {
	Path       string
	PathPrefix string
	//
	GET         ResponseFunc
	PUT         ResponseFunc
	POST        ResponseFunc
	DELETE      ResponseFunc
	GuestOK     bool
	UserOK      bool
	UntrustedOK bool
	AdminOnly   bool
	// contains filtered or unexported fields
}

A Command routes a request to an individual per-verb ResponseFunc

func (*Command) ServeHTTP

func (c *Command) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Daemon

type Daemon struct {
	Version   string
	StartTime time.Time
	// contains filtered or unexported fields
}

A Daemon listens for requests and routes them to the right command

func New

func New(opts *Options) (*Daemon, error)

func (*Daemon) CanStandby

func (d *Daemon) CanStandby() bool

func (*Daemon) Dying

func (d *Daemon) Dying() <-chan struct{}

func (*Daemon) HandleRestart

func (d *Daemon) HandleRestart(t restart.RestartType)

HandleRestart implements overlord.RestartBehavior.

func (*Daemon) Init

func (d *Daemon) Init() error

Init sets up the Daemon's internal workings. Don't call more than once.

func (*Daemon) IsDegraded added in v0.9.3

func (d *Daemon) IsDegraded() bool

func (*Daemon) Overlord

func (d *Daemon) Overlord() *overlord.Overlord

func (*Daemon) RebootIsFine

func (d *Daemon) RebootIsFine(st *state.State) error

RebootIsFine implements part of overlord.RestartBehavior.

func (*Daemon) RebootIsMissing

func (d *Daemon) RebootIsMissing(st *state.State) error

RebootIsMissing implements part of overlord.RestartBehavior.

func (*Daemon) SetDegradedMode

func (d *Daemon) SetDegradedMode(err error)

SetDegradedMode puts the daemon into a degraded mode which will the error given in the "err" argument for commands that are not marked as readonlyOK.

This is useful to report errors to the client when the daemon cannot work because e.g. a sanity check failed or the system is out of diskspace.

When the system is fine again calling "DegradedMode(nil)" is enough to put the daemon into full operation again.

func (*Daemon) Start

func (d *Daemon) Start() error

func (*Daemon) Stop

func (d *Daemon) Stop(sigCh chan<- os.Signal) error

Stop shuts down the Daemon.

type Endpoint

type Endpoint struct {
	Protocol string `json:"protocol"`
	Path     string `json:"path,omitempty"`
	Host     string `json:"host,omitempty"`
	Port     uint16 `json:"port,omitempty"`
}

type HealthCheckInfo

type HealthCheckInfo struct {
	Timestamp time.Time `json:"timestamp"`
	Message   string    `json:"message,omitempty"`
	Code      string    `json:"code,omitempty"`
}

type Mount

type Mount struct {
	Plug           sdk.PlugRef `json:"plug"`
	WorkshopSource string      `json:"workshop-source,omitempty"`
	HostSource     string      `json:"host-source,omitempty"`
	WorkshopTarget string      `json:"workshop-target,omitempty"`
}

type Options

type Options struct {
	// Dir is the workshop directory where all setup is found. Defaults to /var/lib/workshop.
	Dir string

	// SocketPath is an optional path for the unix socket used for the client
	// to communicate with the daemon. Defaults to a hidden (dotted) name inside
	// the workshop directory.
	SocketPath string

	// HTTPAddress is the address for the plain HTTP API server, for example
	// ":4000" to listen on any address, port 4000. If not set, the HTTP API
	// server is not started.
	HTTPAddress string
}

Options holds the daemon setup required for the initialization of a new daemon.

type Response

type Response interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

Response knows how to serve itself, and how to find itself

func AsyncResponse

func AsyncResponse(result map[string]any, change string) Response

func SyncResponse

func SyncResponse(result any, status int) Response

type ResponseFunc

type ResponseFunc func(*Command, *http.Request, *userState) Response

A ResponseFunc handles one of the individual verbs for a method

type ResponseType

type ResponseType string
const (
	ResponseTypeSync  ResponseType = "sync"
	ResponseTypeAsync ResponseType = "async"
	ResponseTypeError ResponseType = "error"
)

type SdkInfo

type SdkInfo struct {
	Name        string           `json:"name"`
	Version     string           `json:"version,omitempty"`
	Channel     string           `json:"channel,omitempty"`
	Source      string           `json:"source,omitempty"`
	Revision    string           `json:"revision"`
	BuiltAt     *time.Time       `json:"built-at,omitempty"`
	InstalledAt time.Time        `json:"installed-at,omitzero"`
	Health      *HealthCheckInfo `json:"health-check,omitempty"`
	Mounts      []*Mount         `json:"mounts,omitempty"`
	Tunnels     []*Tunnel        `json:"tunnels,omitempty"`
}

type Tunnel

type Tunnel struct {
	Plug sdk.PlugRef `json:"plug"`
	From Endpoint    `json:"from"`
	To   Endpoint    `json:"to"`
}

type Workshop

type Workshop struct {
	WorkshopInfo
	Path string `json:"path"`
}

type WorkshopFileInfo

type WorkshopFileInfo struct {
	ProjectId string `json:"project-id"`
	Name      string `json:"name"`
	Path      string `json:"path"`
}

type WorkshopInfo

type WorkshopInfo struct {
	ProjectId string     `json:"project-id"`
	Name      string     `json:"name"`
	Base      string     `json:"base"`
	Status    string     `json:"status"`
	Sdks      []*SdkInfo `json:"sdks,omitempty"`
	Hostname  string     `json:"hostname,omitempty"`
	Notes     []string   `json:"notes,omitempty"`
}

type Workshops

type Workshops struct {
	Workshops []*WorkshopInfo     `json:"workshops"`
	Files     []*WorkshopFileInfo `json:"files"`
}

Jump to

Keyboard shortcuts

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