system

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package system defines the public contract for daemon-level operations in dployr.

It models system health, registration, installation/upgrade, domain requests, mode management, and instance lifecycle sync with base over WebSockets. The concrete implementation lives in internal/system; consumers should depend on the System interface defined here.

Package system provides v1.1 schema for the agent status update

Index

Constants

View Source
const (
	HealthOK       = "ok"
	HealthDegraded = "degraded"
	HealthDown     = "down"
)

Health status

View Source
const (
	SystemStatusHealthy   = "healthy"
	SystemStatusDegraded  = "degraded"
	SystemStatusUnhealthy = "unhealthy"
)

System status

View Source
const (
	ProxyStatusRunning = "running"
	ProxyStatusStopped = "stopped"
	ProxyStatusUnknown = "unknown"
)

Proxy status

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentInfo added in v0.5.0

type AgentInfo struct {
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	BuildDate string `json:"build_date"`
	GoVersion string `json:"go_version"`
	OS        string `json:"os"`
	Arch      string `json:"arch"`
}

AgentInfo - static agent metadata

type AuthDebug

type AuthDebug struct {
	AgentTokenAgeS      int64  `json:"agent_token_age_s"`
	AgentTokenExpiresIn int64  `json:"agent_token_expires_in_s"`
	BootstrapToken      string `json:"bootstrap_token"`
}

AuthDebug provides debugging information about the authentication system.

type AuthDiag added in v0.5.0

type AuthDiag struct {
	TokenAgeSeconds       int64  `json:"token_age_seconds"`
	TokenExpiresInSeconds int64  `json:"token_expires_in_seconds"`
	BootstrapTokenPreview string `json:"bootstrap_token_preview"`
}

type CPUInfo added in v0.5.0

type CPUInfo struct {
	Count         int          `json:"count"`
	UserPercent   float64      `json:"user_percent"`
	SystemPercent float64      `json:"system_percent"`
	IdlePercent   float64      `json:"idle_percent"`
	IOWaitPercent float64      `json:"iowait_percent"`
	LoadAverage   *LoadAvgInfo `json:"load_average,omitempty"` // null on Windows
}

type CPUStats added in v0.5.0

type CPUStats struct {
	User   float64 `json:"user"`
	System float64 `json:"system"`
	Nice   float64 `json:"nice"`
	Idle   float64 `json:"idle"`
	Wait   float64 `json:"wait"`
	HI     float64 `json:"hi"`
	SI     float64 `json:"si"`
	ST     float64 `json:"st"`
}

CPUStats represents CPU usage breakdown

type CertDebug

type CertDebug struct {
	NotAfterRFC3339 string `json:"not_after"`
	DaysRemaining   int    `json:"days_remaining"`
}

CertDebug provides debugging information about the instance's public certificate.

type CertDiag added in v0.5.0

type CertDiag struct {
	NotAfter      string `json:"not_after"`
	DaysRemaining int    `json:"days_remaining"`
}

type DeploymentV1_1 added in v0.5.0

type DeploymentV1_1 struct {
	ID           string            `json:"id"`
	UserID       *string           `json:"user_id,omitempty"`
	Name         string            `json:"name"`
	Description  string            `json:"description"`
	Status       string            `json:"status"` // "pending" | "in_progress" | "completed" | "failed"
	Source       string            `json:"source"` // "remote" | "image" | "local"
	Runtime      RuntimeInfo       `json:"runtime"`
	Remote       *RemoteInfo       `json:"remote,omitempty"`
	Port         int               `json:"port"`
	WorkingDir   *string           `json:"working_dir,omitempty"`
	StaticDir    *string           `json:"static_dir,omitempty"`
	Image        *string           `json:"image,omitempty"`
	RunCommand   *string           `json:"run_command,omitempty"`
	BuildCommand *string           `json:"build_command,omitempty"`
	EnvVars      map[string]string `json:"env_vars,omitempty"`
	Secrets      []SecretRef       `json:"secrets,omitempty"`
	CreatedAt    string            `json:"created_at"`
	UpdatedAt    string            `json:"updated_at"`
}

func FromStoreDeployment added in v0.5.2

func FromStoreDeployment(d *store.Deployment) DeploymentV1_1

FromStoreDeployment converts a store.Deployment to the v1.1 format.

func FromStoreDeployments added in v0.5.2

func FromStoreDeployments(deployments []*store.Deployment) []DeploymentV1_1

FromStoreDeployments converts a slice of store.Deployment to v1.1 format.

type DiagnosticsInfo added in v0.5.0

type DiagnosticsInfo struct {
	Websocket WebsocketDiag `json:"websocket"`
	Tasks     TasksDiag     `json:"tasks"`
	Auth      AuthDiag      `json:"auth"`
	Worker    *WorkerDiag   `json:"worker,omitempty"`
	Cert      *CertDiag     `json:"cert,omitempty"`
}

DiagnosticsInfo - debugging/observability

type DiskDebugEntry added in v0.4.3

type DiskDebugEntry struct {
	Filesystem     string `json:"filesystem"`
	Mountpoint     string `json:"mountpoint"`
	SizeBytes      int64  `json:"size_bytes,omitempty"`
	UsedBytes      int64  `json:"used_bytes,omitempty"`
	AvailableBytes int64  `json:"available_bytes,omitempty"`
}

DiskDebugEntry represents disk usage for a single filesystem/mountpoint.

type DiskInfo added in v0.5.0

type DiskInfo struct {
	Filesystem     string `json:"filesystem"`
	MountPoint     string `json:"mount_point"`
	TotalBytes     int64  `json:"total_bytes"`
	UsedBytes      int64  `json:"used_bytes"`
	AvailableBytes int64  `json:"available_bytes"`
}

type DoctorResult

type DoctorResult struct {
	Status string `json:"status"`
	Output string `json:"output"`
	Error  string `json:"error,omitempty"`
}

type FSCacheInterface added in v0.5.0

type FSCacheInterface interface {
	GetSnapshot() *FSSnapshot
	ListDir(path string, depth, limit int, cursor string) (*FSListResponse, error)
	ReadFile(path string, offset, limit int64) (*FSReadResponse, error)
	WriteFile(req *FSWriteRequest) (*FSOpResponse, error)
	CreateFile(req *FSCreateRequest) (*FSOpResponse, error)
	DeleteFile(req *FSDeleteRequest) (*FSOpResponse, error)
	Watch(path string, recursive bool) error
	Unwatch(path string) error
	SetBroadcaster(broadcaster func(*FSUpdateEvent))
}

FSCacheInterface defines the interface for filesystem cache operations

type FSCreateRequest added in v0.5.0

type FSCreateRequest struct {
	Path    string `json:"path"`
	Type    string `json:"type"`              // "file" | "dir"
	Content string `json:"content,omitempty"` // for files
	Mode    string `json:"mode,omitempty"`    // e.g. "0644" or "0755"
}

FSCreateRequest - create new file or dir

type FSDeleteRequest added in v0.5.0

type FSDeleteRequest struct {
	Path      string `json:"path"`
	Recursive bool   `json:"recursive,omitempty"` // for dirs
}

FSDeleteRequest - delete file or dir

type FSHandler added in v0.5.0

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

FSHandler handles filesystem HTTP requests

func NewFSHandler added in v0.5.0

func NewFSHandler(cache FSCacheInterface, logger *shared.Logger) *FSHandler

NewFSHandler creates a new filesystem handler

func (*FSHandler) HandleCreate added in v0.5.0

func (h *FSHandler) HandleCreate(w http.ResponseWriter, r *http.Request)

HandleCreate handles file/directory creation requests POST /system/fs/create

func (*FSHandler) HandleDelete added in v0.5.0

func (h *FSHandler) HandleDelete(w http.ResponseWriter, r *http.Request)

HandleDelete handles file/directory deletion requests DELETE /system/fs/delete

func (*FSHandler) HandleList added in v0.5.0

func (h *FSHandler) HandleList(w http.ResponseWriter, r *http.Request)

HandleList handles directory listing requests GET /system/fs?path=/var/lib&depth=1&limit=100&cursor=...

func (*FSHandler) HandleRead added in v0.5.0

func (h *FSHandler) HandleRead(w http.ResponseWriter, r *http.Request)

HandleRead handles file read requests GET /system/fs/read?path=/var/lib/file.txt&offset=0&limit=1048576

func (*FSHandler) HandleUnwatch added in v0.5.0

func (h *FSHandler) HandleUnwatch(w http.ResponseWriter, r *http.Request)

HandleUnwatch handles directory unwatch requests POST /system/fs/unwatch

func (*FSHandler) HandleWatch added in v0.5.0

func (h *FSHandler) HandleWatch(w http.ResponseWriter, r *http.Request)

HandleWatch handles directory watch requests POST /system/fs/watch

func (*FSHandler) HandleWrite added in v0.5.0

func (h *FSHandler) HandleWrite(w http.ResponseWriter, r *http.Request)

HandleWrite handles file write requests PUT /system/fs/write

type FSListRequest added in v0.5.0

type FSListRequest struct {
	Path   string `json:"path"`
	Depth  int    `json:"depth"`            // default 1
	Limit  int    `json:"limit"`            // default 100, max 500
	Cursor string `json:"cursor,omitempty"` // for pagination
}

FSListRequest is the HTTP request for lazy directory expansion

type FSListResponse added in v0.5.0

type FSListResponse struct {
	Node       FSNode `json:"node"`
	NextCursor string `json:"next_cursor,omitempty"`
	HasMore    bool   `json:"has_more"`
}

FSListResponse is the HTTP response for directory listing

type FSNode added in v0.5.0

type FSNode struct {
	Path      string    `json:"path"`
	Name      string    `json:"name"`
	Type      string    `json:"type"` // "file" | "dir" | "symlink"
	SizeBytes int64     `json:"size_bytes"`
	ModTime   time.Time `json:"mod_time,omitempty"`

	// Permissions
	Mode  string `json:"mode"`  // e.g. "drwxr-xr-x"
	Owner string `json:"owner"` // username
	Group string `json:"group"` // group name
	UID   int    `json:"uid"`
	GID   int    `json:"gid"`

	// Computed permission flags for the agent's effective user
	Readable   bool `json:"readable"`
	Writable   bool `json:"writable"`
	Executable bool `json:"executable"`

	// Tree structure
	Children   []FSNode `json:"children,omitempty"`
	Truncated  bool     `json:"truncated,omitempty"`
	ChildCount int      `json:"child_count,omitempty"`
}

FSNode represents a filesystem entry with permissions

type FSNodeV1_1 added in v0.5.0

type FSNodeV1_1 struct {
	Path          string        `json:"path"`
	Name          string        `json:"name"`
	Type          string        `json:"type"` // "file" | "directory" | "symlink"
	SizeBytes     int64         `json:"size_bytes"`
	ModifiedAt    string        `json:"modified_at"`
	Permissions   FSPermissions `json:"permissions"`
	Children      []FSNodeV1_1  `json:"children,omitempty"`
	IsTruncated   bool          `json:"is_truncated,omitempty"`
	TotalChildren *int          `json:"total_children,omitempty"`
}

type FSOpResponse added in v0.5.0

type FSOpResponse struct {
	Success bool   `json:"success"`
	Path    string `json:"path"`
	Error   string `json:"error,omitempty"`
}

FSOpResponse - generic response for write/create/delete

type FSPermissions added in v0.5.0

type FSPermissions struct {
	Mode       string `json:"mode"`
	Owner      string `json:"owner"`
	Group      string `json:"group"`
	UID        int    `json:"uid"`
	GID        int    `json:"gid"`
	Readable   bool   `json:"readable"`
	Writable   bool   `json:"writable"`
	Executable bool   `json:"executable"`
}

type FSReadRequest added in v0.5.0

type FSReadRequest struct {
	Path   string `json:"path"`
	Offset int64  `json:"offset,omitempty"` // for large files
	Limit  int64  `json:"limit,omitempty"`  // max bytes to read (default 1MB)
}

FSReadRequest - read file contents

type FSReadResponse added in v0.5.0

type FSReadResponse struct {
	Path      string `json:"path"`
	Content   string `json:"content"`  // base64 for binary, utf8 for text
	Encoding  string `json:"encoding"` // "base64" | "utf8"
	Size      int64  `json:"size"`
	Truncated bool   `json:"truncated"`
}

FSReadResponse - file content response

type FSSnapshot added in v0.5.0

type FSSnapshot struct {
	GeneratedAt time.Time `json:"generated_at"`
	Roots       []FSNode  `json:"roots"`
	Stale       bool      `json:"stale,omitempty"`
}

FSSnapshot is the bounded tree sent in WS updates

type FSUnwatchRequest added in v0.5.0

type FSUnwatchRequest struct {
	Path string `json:"path"`
}

FSUnwatchRequest - request to stop watching a directory

type FSUpdateEvent added in v0.5.0

type FSUpdateEvent struct {
	Type      string    `json:"type"` // "created" | "modified" | "deleted" | "renamed"
	Path      string    `json:"path"`
	Node      *FSNode   `json:"node,omitempty"`     // present for created/modified
	OldPath   string    `json:"old_path,omitempty"` // present for renamed
	Timestamp time.Time `json:"timestamp"`
}

FSUpdateEvent represents a filesystem change event

type FSWatchRequest added in v0.5.0

type FSWatchRequest struct {
	Path      string `json:"path"`
	Recursive bool   `json:"recursive"` // watch subdirectories
}

FSWatchRequest - request to start watching a directory

type FSWriteRequest added in v0.5.0

type FSWriteRequest struct {
	Path     string `json:"path"`
	Content  string `json:"content"`
	Encoding string `json:"encoding"`       // "base64" | "utf8"
	Mode     string `json:"mode,omitempty"` // e.g. "0644", uses default if empty
}

FSWriteRequest - write/overwrite file

type FilesystemInfo added in v0.5.0

type FilesystemInfo struct {
	GeneratedAt string       `json:"generated_at"`
	IsStale     bool         `json:"is_stale"`
	Roots       []FSNodeV1_1 `json:"roots"`
}

FilesystemInfo - filesystem snapshot

type HealthInfo added in v0.5.0

type HealthInfo struct {
	Overall   string `json:"overall"` // "ok" | "degraded" | "down"
	Websocket string `json:"websocket"`
	Tasks     string `json:"tasks"`
	Proxy     string `json:"proxy"`
	Auth      string `json:"auth"` // Advisory only
}

HealthInfo - component health breakdown

type HelloAckV1 added in v0.4.2

type HelloAckV1 struct {
	Schema          string    `json:"schema"`
	Accept          bool      `json:"accept"`
	Reason          string    `json:"reason,omitempty"`
	FeaturesEnabled []string  `json:"features_enabled,omitempty"`
	ServerTime      time.Time `json:"server_time"`
}

HelloAckV1 is sent by base to acknowledge the agent hello.

type HelloV1 added in v0.4.2

type HelloV1 struct {
	Schema           string            `json:"schema"`
	InstanceID       string            `json:"instance_id"`
	BuildInfo        version.BuildInfo `json:"build_info"`
	Platform         PlatformInfo      `json:"platform"`
	Capabilities     []string          `json:"capabilities,omitempty"`
	SchemasSupported []string          `json:"schemas_supported,omitempty"`
}

HelloV1 is sent by the agent when establishing a WebSocket connection.

type InstallRequest

type InstallRequest struct {
	Version string `json:"version"`
	Token   string `json:"token,omitempty"`
}

InstallRequest is used to request an installation of dployr.

type LoadAverage added in v0.5.0

type LoadAverage struct {
	One     float64 `json:"one"`
	Five    float64 `json:"five"`
	Fifteen float64 `json:"fifteen"`
}

LoadAverage represents system load averages.

type LoadAvgInfo added in v0.5.0

type LoadAvgInfo struct {
	OneMinute     float64 `json:"one_minute"`
	FiveMinute    float64 `json:"five_minute"`
	FifteenMinute float64 `json:"fifteen_minute"`
}

type MemoryInfo added in v0.5.0

type MemoryInfo struct {
	TotalBytes       int64 `json:"total_bytes"`
	UsedBytes        int64 `json:"used_bytes"`
	FreeBytes        int64 `json:"free_bytes"`
	AvailableBytes   int64 `json:"available_bytes"`
	BufferCacheBytes int64 `json:"buffer_cache_bytes"`
}

type MemoryStats added in v0.5.0

type MemoryStats struct {
	Total       float64 `json:"total"`
	Free        float64 `json:"free"`
	Used        float64 `json:"used"`
	BufferCache float64 `json:"buffer_cache"`
}

MemoryStats represents memory usage (in MiB).

type Mode

type Mode string

Mode represents the current mode. "ready" – normal operation, syncer active. "updating" – in the middle of an update/installation cycle.

const (
	ModeReady    Mode = "ready"
	ModeUpdating Mode = "updating"
)

type ModeStatus

type ModeStatus struct {
	Mode Mode `json:"mode"`
}

ModeStatus describes the current daemon mode.

type PlatformInfo added in v0.4.2

type PlatformInfo struct {
	OS   string `json:"os"`
	Arch string `json:"arch"`
}

PlatformInfo describes the runtime platform of the agent.

type ProcessInfo added in v0.5.0

type ProcessInfo struct {
	PID      int     `json:"pid"`
	User     string  `json:"user"`
	Priority int     `json:"priority"`
	Nice     int     `json:"nice"`
	VirtMem  int64   `json:"virt_mem"`
	ResMem   int64   `json:"res_mem"`
	ShrMem   int64   `json:"shr_mem"`
	State    string  `json:"state"`
	CPUPct   float64 `json:"cpu_pct"`
	MEMPct   float64 `json:"mem_pct"`
	Time     string  `json:"time"`
	Command  string  `json:"command"`
}

ProcessInfo represents a single process's resource usage matching top output format.

type ProcessInfoV1_1 added in v0.5.0

type ProcessInfoV1_1 struct {
	PID                 int     `json:"pid"`
	User                string  `json:"user"`
	Priority            int     `json:"priority"`
	Nice                int     `json:"nice"`
	VirtualMemoryBytes  int64   `json:"virtual_memory_bytes"`
	ResidentMemoryBytes int64   `json:"resident_memory_bytes"`
	SharedMemoryBytes   int64   `json:"shared_memory_bytes"`
	State               string  `json:"state"` // "running" | "sleeping" | "stopped" | "zombie" | "idle"
	CPUPercent          float64 `json:"cpu_percent"`
	MemoryPercent       float64 `json:"memory_percent"`
	CPUTime             string  `json:"cpu_time"`
	Command             string  `json:"command"`
}

type ProcessSummary added in v0.5.0

type ProcessSummary struct {
	Total    int `json:"total"`
	Running  int `json:"running"`
	Sleeping int `json:"sleeping"`
	Stopped  int `json:"stopped"`
	Zombie   int `json:"zombie"`
}

type ProcessesInfo added in v0.5.0

type ProcessesInfo struct {
	Summary ProcessSummary    `json:"summary"`
	List    []ProcessInfoV1_1 `json:"list,omitempty"`
}

ProcessesInfo - process metrics

type ProxyInfo added in v0.5.0

type ProxyInfo struct {
	Type       string           `json:"type"`   // "caddy" | "nginx" | "apache" | "traefik" | "custom"
	Status     string           `json:"status"` // "running" | "stopped" | "unknown"
	Version    *string          `json:"version,omitempty"`
	RouteCount int              `json:"route_count"`
	Routes     []ProxyRouteInfo `json:"routes,omitempty"`
}

ProxyInfo - reverse proxy state

type ProxyRouteInfo added in v0.5.0

type ProxyRouteInfo struct {
	Domain   string  `json:"domain"`
	Upstream string  `json:"upstream"`
	Template string  `json:"template"` // "static" | "reverse_proxy" | "php_fastcgi"
	Root     *string `json:"root,omitempty"`
	Status   string  `json:"status"` // "active" | "inactive" | "error"
}

type RebootRequest added in v0.4.10

type RebootRequest struct {
	Force bool `json:"force,omitempty"`
}

RebootRequest is used to request a system reboot.

type RebootResponse added in v0.4.10

type RebootResponse struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

RebootResponse is returned after initiating a system reboot.

type RegisterInstanceRequest

type RegisterInstanceRequest struct {
	Claim      string `json:"claim"`
	InstanceID string `json:"instance_id"`
	Issuer     string `json:"issuer"`
	Audience   string `json:"audience"`
}

RegisterInstanceRequest is used to request a registration of an instance.

type RegistrationStatus

type RegistrationStatus struct {
	Registered bool `json:"registered"`
}

RegistrationStatus reports whether the instance has been registered

type RemoteInfo added in v0.5.0

type RemoteInfo struct {
	URL        string `json:"url"`
	Branch     string `json:"branch"`
	CommitHash string `json:"commit_hash"`
}

type RequestDomainRequest

type RequestDomainRequest struct {
	Token string `json:"token"`
}

RequestDomainRequest is used to request a domain for an instance.

type RequestDomainResponse

type RequestDomainResponse struct {
	Success    bool   `json:"success"`
	InstanceID string `json:"instanceId,omitempty"`
	Domain     string `json:"domain,omitempty"`
	Issuer     string `json:"issuer,omitempty"`
	Audience   string `json:"audience,omitempty"`
}

RequestDomainResponse is returned after requesting a domain for an instance.

type ResourcesInfo added in v0.5.0

type ResourcesInfo struct {
	CPU    CPUInfo    `json:"cpu"`
	Memory MemoryInfo `json:"memory"`
	Swap   SwapInfo   `json:"swap"`
	Disks  []DiskInfo `json:"disks,omitempty"`
}

ResourcesInfo - system resource metrics

type RestartRequest added in v0.4.8

type RestartRequest struct {
	Force bool `json:"force,omitempty"`
}

RestartRequest is used to request a system restart.

type RestartResponse added in v0.4.8

type RestartResponse struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

RestartResponse is returned after initiating a system restart.

type RuntimeInfo added in v0.5.0

type RuntimeInfo struct {
	Type    string  `json:"type"` // "static"|"golang"|"php"|"python"|"nodejs"|"ruby"|"dotnet"|"java"|"docker"|"k3s"|"custom"
	Version *string `json:"version,omitempty"`
}

type SecretRef added in v0.5.0

type SecretRef struct {
	Key    string `json:"key"`
	Source string `json:"source"` // "local"
}

type ServiceHandler

type ServiceHandler struct {
	Svc System
}

func NewServiceHandler

func NewServiceHandler(s System) *ServiceHandler

func (*ServiceHandler) GetInfo

func (h *ServiceHandler) GetInfo(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) GetMode

func (h *ServiceHandler) GetMode(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) Install

func (h *ServiceHandler) Install(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) Reboot added in v0.4.10

func (h *ServiceHandler) Reboot(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) RegisterInstance

func (h *ServiceHandler) RegisterInstance(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) Registered

func (h *ServiceHandler) Registered(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) RequestDomain

func (h *ServiceHandler) RequestDomain(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) Restart added in v0.4.8

func (h *ServiceHandler) Restart(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) RunDoctor

func (h *ServiceHandler) RunDoctor(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) SetMode

func (h *ServiceHandler) SetMode(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) SystemStatus

func (h *ServiceHandler) SystemStatus(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) Tasks

func (h *ServiceHandler) Tasks(w http.ResponseWriter, r *http.Request)

func (*ServiceHandler) UpdateBootstrapToken

func (h *ServiceHandler) UpdateBootstrapToken(w http.ResponseWriter, r *http.Request)

type ServiceV1_1 added in v0.5.0

type ServiceV1_1 struct {
	ID             string            `json:"id"`
	Name           string            `json:"name"`
	Description    string            `json:"description"`
	Runtime        string            `json:"runtime"`
	RuntimeVersion *string           `json:"runtime_version,omitempty"`
	Port           int               `json:"port"`
	WorkingDir     *string           `json:"working_dir,omitempty"`
	StaticDir      *string           `json:"static_dir,omitempty"`
	Image          *string           `json:"image,omitempty"`
	RunCommand     *string           `json:"run_command,omitempty"`
	BuildCommand   *string           `json:"build_command,omitempty"`
	EnvVars        map[string]string `json:"env_vars"`
	Secrets        []SecretRef       `json:"secrets"`
	RemoteURL      *string           `json:"remote_url,omitempty"`
	Branch         *string           `json:"branch,omitempty"`
	CommitHash     *string           `json:"commit_hash,omitempty"`
	CreatedAt      string            `json:"created_at"`
	UpdatedAt      string            `json:"updated_at"`
}

func FromStoreService added in v0.5.2

func FromStoreService(s *store.Service) ServiceV1_1

FromStoreService converts a store.Service to the v1.1 format.

func FromStoreServices added in v0.5.2

func FromStoreServices(services []*store.Service) []ServiceV1_1

FromStoreServices converts a slice of store.Service to v1.1 format.

type SetModeRequest

type SetModeRequest struct {
	Mode Mode `json:"mode"`
}

SetModeRequest is used by the agent to change the daemon mode.

type StatusInfo added in v0.5.0

type StatusInfo struct {
	State         string `json:"state"` // "healthy" | "degraded" | "unhealthy"
	Mode          string `json:"mode"`  // "ready" | "updating" | "maintenance"
	UptimeSeconds int64  `json:"uptime_seconds"`
}

StatusInfo - operational status

type SwapInfo added in v0.5.0

type SwapInfo struct {
	TotalBytes     int64 `json:"total_bytes"`
	UsedBytes      int64 `json:"used_bytes"`
	FreeBytes      int64 `json:"free_bytes"`
	AvailableBytes int64 `json:"available_bytes"`
}

type SwapStats added in v0.5.0

type SwapStats struct {
	Total     float64 `json:"total"`
	Free      float64 `json:"free"`
	Used      float64 `json:"used"`
	Available float64 `json:"available"`
}

SwapStats represents swap usage (in MiB).

type System

type System interface {
	// GetInfo returns system information.
	GetInfo(ctx context.Context) (utils.SystemInfo, error)
	// RunDoctor runs the system doctor script and returns its combined output.
	RunDoctor(ctx context.Context) (string, error)
	// Install installs dployr; if version is empty, the latest version is installed.
	Install(ctx context.Context, req InstallRequest) (string, error)
	// SystemStatus returns high-level health information.
	SystemStatus(ctx context.Context) (SystemStatus, error)
	// RequestDomain requests and assigns a new random domain from base to the system.
	RequestDomain(ctx context.Context, req RequestDomainRequest) (RequestDomainResponse, error)
	// RegisterInstance registers the system with the base and assigns an instance id
	RegisterInstance(ctx context.Context, req RegisterInstanceRequest) error
	// GetTasks returns a summary of tasks for the given status (e.g. "pending", "completed").
	GetTasks(ctx context.Context, status string, excludeSystem bool) (TaskSummary, error)
	// GetMode returns the current daemon mode.
	GetMode(ctx context.Context) (ModeStatus, error)
	// SetMode updates the daemon mode.
	SetMode(ctx context.Context, req SetModeRequest) (ModeStatus, error)
	// UpdateBootstrapToken updates the bootstrap token.
	UpdateBootstrapToken(ctx context.Context, req UpdateBootstrapTokenRequest) error
	// IsRegistered returns true if this daemon has been registered with base.
	IsRegistered(ctx context.Context) (RegistrationStatus, error)
	// Restart initiates a system restart after ensuring no tasks are running.
	Restart(ctx context.Context, req RestartRequest) (RestartResponse, error)
	// Reboot initiates an OS reboot.
	Reboot(ctx context.Context, req RebootRequest) (RebootResponse, error)
}

System defines an interface for system operations.

type SystemDebug

type SystemDebug struct {
	WS     WSDebug               `json:"ws"`
	Tasks  TasksDebug            `json:"tasks"`
	Auth   *AuthDebug            `json:"auth,omitempty"`
	Cert   *CertDebug            `json:"cert,omitempty"`
	System *SystemResourcesDebug `json:"system,omitempty"`
}

SystemDebug provides debugging information about the daemon.

type SystemHealth

type SystemHealth struct {
	Overall string `json:"overall"` // ok|degraded|down
	WS      string `json:"ws"`
	Tasks   string `json:"tasks"`
	Auth    string `json:"auth"`
}

SystemHealth provides high-level health information about the daemon.

type SystemManager

type SystemManager struct{}

func NewSystemManager

func NewSystemManager() *SystemManager

type SystemProxyStatus

type SystemProxyStatus struct {
	Status string `json:"status"`
	Routes int    `json:"routes"`
}

SystemProxyStatus describes proxy health and routing information.

type SystemResourcesDebug added in v0.4.3

type SystemResourcesDebug struct {
	CPUCount      int              `json:"cpu_count"`
	MemTotalBytes int64            `json:"mem_total_bytes,omitempty"`
	MemUsedBytes  int64            `json:"mem_used_bytes,omitempty"`
	MemFreeBytes  int64            `json:"mem_free_bytes,omitempty"`
	Disks         []DiskDebugEntry `json:"disks,omitempty"`
	Workers       int              `json:"workers,omitempty"`
}

SystemResourcesDebug provides high-level system resource information for debugging.

type SystemStatus

type SystemStatus struct {
	Status      string             `json:"status"`
	Mode        Mode               `json:"mode"`
	Uptime      string             `json:"uptime"`
	Deployments []store.Deployment `json:"deployments"`
	Services    []store.Service    `json:"services"`
	Apps        []proxy.App        `json:"proxies"`
	Proxy       SystemProxyStatus  `json:"proxy"`
	Health      SystemHealth       `json:"health"`
	Debug       *SystemDebug       `json:"debug,omitempty"`
}

SystemStatus describes high-level health information about the daemon.

type SystemTop added in v0.5.0

type SystemTop struct {
	Header    TopHeader     `json:"header"`
	Tasks     TaskStats     `json:"tasks"`
	CPU       CPUStats      `json:"cpu"`
	Memory    MemoryStats   `json:"memory"`
	Swap      SwapStats     `json:"swap"`
	Processes []ProcessInfo `json:"processes"`
}

SystemTop represents a snapshot of system resource usage (like `top` output).

type TaskStats added in v0.5.0

type TaskStats struct {
	Total    int `json:"total"`
	Running  int `json:"running"`
	Sleeping int `json:"sleeping"`
	Stopped  int `json:"stopped"`
	Zombie   int `json:"zombie"`
}

TaskStats represents task/process counts by state.

type TaskSummary

type TaskSummary struct {
	Count int `json:"count"`
}

TaskSummary represents a simple count of tasks for a given status.

type TasksDebug

type TasksDebug struct {
	Inflight          int    `json:"inflight"`
	DoneUnsent        int    `json:"done_unsent"`
	LastTaskID        string `json:"last_task_id,omitempty"`
	LastTaskStatus    string `json:"last_task_status,omitempty"`
	LastTaskDurMs     int64  `json:"last_task_dur_ms,omitempty"`
	LastTaskAtRFC3339 string `json:"last_task_at,omitempty"`
}

TasksDebug provides debugging information about the task queue.

type TasksDiag added in v0.5.0

type TasksDiag struct {
	InflightCount      int     `json:"inflight_count"`
	UnsentCount        int     `json:"unsent_count"`
	LastTaskID         *string `json:"last_task_id,omitempty"`
	LastTaskStatus     *string `json:"last_task_status,omitempty"`
	LastTaskDurationMs *int64  `json:"last_task_duration_ms,omitempty"`
	LastTaskAt         *string `json:"last_task_at,omitempty"`
}

type TopCollectorInterface added in v0.5.0

type TopCollectorInterface interface {
	Collect(ctx context.Context, sortBy string, limit int) (*SystemTop, error)
	CollectSummary(ctx context.Context) (*SystemTop, error)
}

TopCollectorInterface defines the interface for collecting system top data.

type TopHandler added in v0.5.0

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

TopHandler handles /system/top requests.

func NewTopHandler added in v0.5.0

func NewTopHandler(collector TopCollectorInterface, logger *shared.Logger) *TopHandler

NewTopHandler creates a new TopHandler.

func (*TopHandler) HandleTop added in v0.5.0

func (h *TopHandler) HandleTop(w http.ResponseWriter, r *http.Request)

HandleTop handles GET /system/top requests.

type TopHeader added in v0.5.0

type TopHeader struct {
	Time    string      `json:"time"`
	Uptime  string      `json:"uptime"`
	Users   int         `json:"users"`
	LoadAvg LoadAverage `json:"load_avg"`
}

TopHeader represents the header information from top.

type TopRequest added in v0.5.0

type TopRequest struct {
	SortBy string `json:"sort_by"` // "cpu" or "mem"
	Limit  int    `json:"limit"`   // max processes to return
}

TopRequest represents query parameters for the /system/top endpoint.

type UpdateBootstrapTokenRequest

type UpdateBootstrapTokenRequest struct {
	Token string `json:"token"`
}

UpdateBootstrapTokenRequest is used to bootstrap token

type UpdateV1 added in v0.4.3

type UpdateV1 struct {
	Schema      string             `json:"schema"`
	Seq         uint64             `json:"seq"`
	Epoch       string             `json:"epoch"`
	Full        bool               `json:"full"`
	InstanceID  string             `json:"instance_id"`
	BuildInfo   version.BuildInfo  `json:"build_info"`
	Platform    PlatformInfo       `json:"platform"`
	Status      string             `json:"status"`
	Mode        Mode               `json:"mode"`
	Uptime      string             `json:"uptime"`
	Deployments []store.Deployment `json:"deployments"`
	Services    []store.Service    `json:"services"`
	Apps        []proxy.App        `json:"proxies"`
	Proxy       SystemProxyStatus  `json:"proxy"`
	Health      SystemHealth       `json:"health"`
	Debug       *SystemDebug       `json:"debug,omitempty"`
	FS          *FSSnapshot        `json:"fs,omitempty"`
	Top         *SystemTop         `json:"top,omitempty"`
}

UpdateV1 represents the status update payload sent from the agent to base. This struct defines the core schema relied upon by clients interacting with the dployr API.

type UpdateV1_1 added in v0.5.0

type UpdateV1_1 struct {
	Schema      string          `json:"schema"` // "v1.1"
	Sequence    uint64          `json:"sequence"`
	Epoch       string          `json:"epoch"`
	InstanceID  string          `json:"instance_id"`
	Timestamp   string          `json:"timestamp"` // RFC3339
	IsFullSync  bool            `json:"is_full_sync"`
	Agent       *AgentInfo      `json:"agent,omitempty"`
	Status      StatusInfo      `json:"status"`
	Health      HealthInfo      `json:"health"`
	Resources   ResourcesInfo   `json:"resources"`
	Workloads   *WorkloadsInfo  `json:"workloads,omitempty"`
	Proxy       ProxyInfo       `json:"proxy"`
	Processes   ProcessesInfo   `json:"processes"`
	Filesystem  *FilesystemInfo `json:"filesystem,omitempty"`
	Diagnostics DiagnosticsInfo `json:"diagnostics"`
}

UpdateV1_1 is the v1.1 status update schema

type WSDebug

type WSDebug struct {
	Connected            bool    `json:"connected"`
	LastConnectAtRFC3339 string  `json:"last_connect_at"`
	ReconnectsSinceStart uint64  `json:"reconnects_since_start"`
	LastError            *string `json:"last_error,omitempty"`
}

WSDebug provides debugging information about the WebSocket connection.

type WebsocketDiag added in v0.5.0

type WebsocketDiag struct {
	IsConnected     bool    `json:"is_connected"`
	LastConnectedAt *string `json:"last_connected_at,omitempty"`
	ReconnectCount  uint64  `json:"reconnect_count"`
	LastError       *string `json:"last_error,omitempty"`
}

type WorkerDiag added in v0.5.0

type WorkerDiag struct {
	MaxConcurrent int `json:"max_concurrent"`
	ActiveJobs    int `json:"active_jobs"`
}

type WorkloadsInfo added in v0.5.0

type WorkloadsInfo struct {
	Deployments []DeploymentV1_1 `json:"deployments"`
	Services    []ServiceV1_1    `json:"services"`
}

WorkloadsInfo - deployments and services

Jump to

Keyboard shortcuts

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