system

package
v0.6.42 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Overview

Package system implements the daemon's system service: sync, install/upgrade, registration, and health. It owns the WebSocket connection to base, periodic pulls and state updates, and local task result handling with deduplication. Internal-only; external code should use pkg/core/system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildUpdateV1_1 added in v0.5.0

func BuildUpdateV1_1(
	ctx context.Context,
	cfg *shared.Config,
	seq uint64,
	epoch string,
	isFullSync bool,
	instStore store.InstanceStore,
	deployStore store.DeploymentStore,
	svcStore store.ServiceStore,
	proxyHandler proxy.HandleProxy,
	fs *FileSystem,
	topCollector *TopCollector,
	watchDog *WatchDog,
	workerMaxConcurrent int,
	workerActiveJobs int,
	l *shared.Logger,
) (*system.UpdateV1_1, error)

BuildUpdateV1_1 constructs the v1.1 status update

func WSConnected

func WSConnected() bool

func WSLastConnect

func WSLastConnect() (t time.Time)

func WSLastError

func WSLastError() *string

func WSReconnectsSinceStart

func WSReconnectsSinceStart() uint64

Types

type AccessTokenProvider

type AccessTokenProvider interface {
	GetAccessToken(ctx context.Context) (string, error)
}

type DefaultService

type DefaultService struct {
	// contains filtered or unexported fields
}

func NewDefaultService

func NewDefaultService(cfg *shared.Config, store store.InstanceStore, results store.TaskResultStore) *DefaultService

func (*DefaultService) GetInfo

func (s *DefaultService) GetInfo(ctx context.Context) (utils.SystemInfo, error)

func (*DefaultService) GetMode

func (s *DefaultService) GetMode(ctx context.Context) (system.ModeStatus, error)

GetMode returns the current daemon mode.

func (*DefaultService) GetTasks

func (s *DefaultService) GetTasks(ctx context.Context, status string, excludeSystem bool) (system.TaskSummary, error)

func (*DefaultService) Install

func (*DefaultService) IsRegistered

func (s *DefaultService) IsRegistered(ctx context.Context) (system.RegistrationStatus, error)

func (*DefaultService) Reboot added in v0.4.10

func (*DefaultService) RegisterInstance

func (s *DefaultService) RegisterInstance(ctx context.Context, req system.RegisterInstanceRequest) error

func (*DefaultService) RequestDomain

During the installation process, this method is used to register the instance with Dployr Base, used for routing traffic to this instance instead of directly hitting it. This is to ensure HTTPS traffic is enforced on dployr instance. Please refer to the documentation at https://docs.dployr.io/installation for more details.

func (*DefaultService) Restart added in v0.4.8

func (*DefaultService) RunDoctor

func (s *DefaultService) RunDoctor(ctx context.Context) (string, error)

func (*DefaultService) SetMode

SetMode updates the daemon mode.

func (*DefaultService) SystemStatus

func (s *DefaultService) SystemStatus(ctx context.Context) (system.SystemStatus, error)

func (*DefaultService) UpdateBootstrapToken

func (s *DefaultService) UpdateBootstrapToken(ctx context.Context, req system.UpdateBootstrapTokenRequest) error

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor(logger *shared.Logger, cfg *shared.Config, handler http.Handler, tokens AccessTokenProvider, auth pkgAuth.Authenticator) *Executor

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, task *tasks.Task) *tasks.Result

Execute runs a task by converting it to an HTTP request and routing it internally.

func (*Executor) SetTerminalHandler added in v0.5.9

func (e *Executor) SetTerminalHandler(h TerminalHandler)

func (*Executor) SetWSConn added in v0.4.6

func (e *Executor) SetWSConn(conn *websocket.Conn)

type FileSystem added in v0.5.0

type FileSystem struct {
	// contains filtered or unexported fields
}

FileSystem provides cached filesystem snapshots with async refresh

func NewFS added in v0.5.0

func NewFS() *FileSystem

NewFS creates a new filesystem cache

func (*FileSystem) Close added in v0.5.0

func (c *FileSystem) Close() error

Close stops the watcher and cleans up resources

func (*FileSystem) CreateFile added in v0.5.0

func (c *FileSystem) CreateFile(req *system.FSCreateRequest) (*system.FSOpResponse, error)

CreateFile creates a new file or directory

func (*FileSystem) DeleteFile added in v0.5.0

func (c *FileSystem) DeleteFile(req *system.FSDeleteRequest) (*system.FSOpResponse, error)

DeleteFile deletes a file or directory

func (*FileSystem) GetSnapshot added in v0.5.0

func (c *FileSystem) GetSnapshot() *system.FSSnapshot

GetSnapshot returns the current snapshot, triggering refresh if stale

func (*FileSystem) ListDir added in v0.5.0

func (c *FileSystem) ListDir(path string, depth, limit int, cursor string) (*system.FSListResponse, error)

ListDir lists a directory with pagination

func (*FileSystem) ReadFile added in v0.5.0

func (c *FileSystem) ReadFile(path string, offset, limit int64) (*system.FSReadResponse, error)

ReadFile reads file contents

func (*FileSystem) SetBroadcaster added in v0.5.0

func (c *FileSystem) SetBroadcaster(broadcaster func(*system.FSUpdateEvent))

SetBroadcaster sets the callback function for broadcasting filesystem events

func (*FileSystem) Unwatch added in v0.5.0

func (c *FileSystem) Unwatch(path string) error

Unwatch stops watching a directory

func (*FileSystem) Watch added in v0.5.0

func (c *FileSystem) Watch(path string, recursive bool) error

Watch starts watching a directory for changes

func (*FileSystem) WriteFile added in v0.5.0

func (c *FileSystem) WriteFile(req *system.FSWriteRequest) (*system.FSOpResponse, error)

WriteFile writes content to a file

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(cfg *shared.Config, inst store.InstanceStore, results store.TaskResultStore) *Metrics

func (*Metrics) ServeHTTP

func (m *Metrics) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServiceHealth added in v0.6.41

type ServiceHealth string

ServiceHealth is the binary health state of a service container.

const (
	HealthHealthy  ServiceHealth = "healthy"
	HealthDegraded ServiceHealth = "degraded"
)

type Syncer

type Syncer struct {
	// contains filtered or unexported fields
}

func NewSyncer

func NewSyncer(cfg *shared.Config, logger *shared.Logger, instStore store.InstanceStore, resStore store.TaskResultStore, deployStore store.DeploymentStore, svcStore store.ServiceStore, proxyHandler proxy.HandleProxy, handler http.Handler, auth pkgAuth.Authenticator, fs *FileSystem, workerMaxConcurrent int, workerActiveJobs func() int) *Syncer

func (*Syncer) Executor added in v0.5.9

func (s *Syncer) Executor() *Executor

func (*Syncer) RequestFullSync added in v0.6.9

func (s *Syncer) RequestFullSync()

func (*Syncer) Start

func (s *Syncer) Start(ctx context.Context)

type TerminalHandler added in v0.5.9

type TerminalHandler interface {
	HandleRelaySession(ctx context.Context, conn *websocket.Conn, sessionID string, cols, rows uint16) error
}

type TopCollector added in v0.5.0

type TopCollector struct{}

TopCollector collects system resource usage data.

func NewTopCollector added in v0.5.0

func NewTopCollector() *TopCollector

NewTopCollector creates a new TopCollector.

func (*TopCollector) Collect added in v0.5.0

func (c *TopCollector) Collect(ctx context.Context, sortBy string, limit int) (*system.SystemTop, error)

Collect gathers a snapshot of system resource usage. sortBy can be "cpu" or "mem", limit is the max number of processes to return.

func (*TopCollector) CollectSummary added in v0.5.0

func (c *TopCollector) CollectSummary(ctx context.Context) (*system.SystemTop, error)

CollectSummary returns a lightweight summary suitable for WS updates. Returns top 10 processes by CPU.

type WatchDog added in v0.6.41

type WatchDog struct {
	// contains filtered or unexported fields
}

WatchDog probes each service's HTTP endpoint from the host and maintains a "healthy" | "degraded" result per service name.

func NewHealthPoller added in v0.6.41

func NewHealthPoller() *WatchDog

func (*WatchDog) Get added in v0.6.41

func (p *WatchDog) Get(serviceName string) string

Get returns the last known health result for a service. Returns "degraded" if no result has been recorded yet (assume degraded until proven otherwise).

func (*WatchDog) Remove added in v0.6.41

func (p *WatchDog) Remove(serviceName string)

Remove clears the health state for a service (called on decommission/stop).

func (*WatchDog) Run added in v0.6.41

func (p *WatchDog) Run(ctx context.Context, getServices func() []WatchTarget)

Run starts the polling loop. It calls getServices on each tick to discover what to probe. Pass the context to stop the loop.

type WatchTarget added in v0.6.41

type WatchTarget struct {
	Name     string
	HostPort int
	Path     string // optional; defaults to "/". Must be an absolute path (e.g. "/healthz"), not a full URL.
}

WatchTarget describes a single service to probe.

Jump to

Keyboard shortcuts

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