Documentation
¶
Index ¶
- Constants
- Variables
- func First[T1, T2 any](t1 T1, _ T2) T1
- func VersionCommit() string
- type ComponentStatus
- type ComponentStatusData
- type Config
- type Event
- type EventData
- type EventListener
- type EventType
- type FileInstaller
- func (i *FileInstaller) Close() (err error)
- func (i *FileInstaller) Fail()
- func (i *FileInstaller) Rate() float64
- func (i *FileInstaller) Received() float64
- func (i *FileInstaller) Wait() error
- func (i *FileInstaller) Write(p []byte) (n int, err error)
- func (i *FileInstaller) WriteAt(p []byte, offset int64) (n int, err error)
- type FileInstallerCfg
- type Installer
- type InstallerCfg
- type MacvlanOpts
- type NetworkOpts
- type Server
- func (s *Server) AddEventListener(ch chan<- Event, filter func(Event) bool) set.Handle
- func (s *Server) DockerComposeStatus(ns string) (svc.DockerComposeStatus, error)
- func (s *Server) DockerComposeStatuses() (map[string]svc.DockerComposeStatus, error)
- func (s *Server) IsServiceRunning(name string) (bool, error)
- func (s *Server) NewInstaller(cfg InstallerCfg) (*Installer, error)
- func (s *Server) PublishEvent(event Event)
- func (s *Server) RemoveEventListener(h set.Handle)
- func (s *Server) RemoveService(name string) error
- func (s *Server) SSHHandler(session gssh.Session)
- func (s *Server) ServeInternalRegistry(listener net.Listener) error
- func (s *Server) ServeSSH(listener net.Listener) error
- func (s *Server) Shutdown()
- func (s *Server) Start()
- func (s *Server) SystemdStatus(ns string) (svc.Status, error)
- func (s *Server) SystemdStatuses() (map[string]svc.Status, error)
- func (s *Server) WebMux() (http.Handler, error)
- type ServerInfo
- type ServiceDataType
- type ServiceEnabler
- type ServiceRunner
- type ServiceStatusData
- type TailscaleOpts
Constants ¶
const ( // SystemService is the name of the system meta-service that manages the server. SystemService = "sys" // CatchService is the name of the self-service that manages the server. CatchService = "catch" )
const ( ServiceDataTypeService ServiceDataType = "service" ServiceDataTypeCron ServiceDataType = "cron" ServiceDataTypeDocker ServiceDataType = "docker" ServiceDataTypeUnknown ServiceDataType = "unknown" ComponentStatusStarting ComponentStatus = "starting" ComponentStatusRunning ComponentStatus = "running" ComponentStatusStopping ComponentStatus = "stopping" ComponentStatusStopped ComponentStatus = "stopped" ComponentStatusUnknown ComponentStatus = "unknown" )
Variables ¶
var DockerStatusesUnknown = svc.DockerComposeStatus{}
Functions ¶
func VersionCommit ¶
func VersionCommit() string
VersionCommit returns the commit hash of the current build.
Types ¶
type ComponentStatus ¶
type ComponentStatus string
func ComponentStatusFromServiceStatus ¶
func ComponentStatusFromServiceStatus(st svc.Status) ComponentStatus
type ComponentStatusData ¶
type ComponentStatusData struct {
Name string `json:"name"`
Status ComponentStatus `json:"status"`
}
type Config ¶
type Config struct {
Signer ssh.Signer
DB *db.Store
DefaultUser string
RootDir string
ServicesRoot string
MountsRoot string
InternalRegistryAddr string
ExternalRegistryAddr string
RegistryRoot string
LocalClient *tailscale.LocalClient
}
Config consists of an `Address` (ip:port) and an `SSHConfig` that is used to configure the SSH server.
type EventData ¶
type EventData struct {
Data any
}
func (EventData) MarshalJSON ¶
MarshalJSON returns m as the JSON encoding of m.
type EventListener ¶
type EventListener struct {
// contains filtered or unexported fields
}
type EventType ¶
type EventType string
const ( EventTypeUnknown EventType = "Unknown" EventTypeHeartbeat EventType = "Heartbeat" EventTypeServiceStatusChanged EventType = "ServiceStatusChanged" EventTypeServiceDeleted EventType = "ServiceDeleted" EventTypeServiceCreated EventType = "ServiceCreated" EventTypeServiceConfigChanged EventType = "ServiceConfigChanged" EventTypeServiceConfigStaged EventType = "ServiceConfigStaged" )
type FileInstaller ¶
func NewFileInstaller ¶
func NewFileInstaller(s *Server, cfg FileInstallerCfg) (*FileInstaller, error)
func (*FileInstaller) Close ¶
func (i *FileInstaller) Close() (err error)
Close closes the temporary file and installs the service.
func (*FileInstaller) Fail ¶
func (i *FileInstaller) Fail()
func (*FileInstaller) Rate ¶
func (i *FileInstaller) Rate() float64
func (*FileInstaller) Received ¶
func (i *FileInstaller) Received() float64
func (*FileInstaller) Wait ¶
func (i *FileInstaller) Wait() error
type FileInstallerCfg ¶
type FileInstallerCfg struct {
InstallerCfg
EnvFile bool
Args []string
Network NetworkOpts
StageOnly bool
NoBinary bool
// NewCmd, if set, will be used to create a new exec.Cmd.
NewCmd func(name string, arg ...string) *exec.Cmd
}
type Installer ¶
type Installer struct {
NewCmd func(name string, arg ...string) *exec.Cmd
// contains filtered or unexported fields
}
Installer is an io.WriteCloser that writes the received binary to a file and installs the service when closed.
func (*Installer) InstallGen ¶
type InstallerCfg ¶
type InstallerCfg struct {
ServiceName string
User string
// Printer is a function to print messages to the client.
Printer func(string, ...any) `json:"-"`
// ClientOut is the writer to send messages to stdout on the client.
ClientOut io.Writer `json:"-"`
// Timer, if set, specifies that the service should be installed as a timer service.
Timer *svc.TimerConfig `json:"-"`
// SSHSessionCloser is an io.Closer that closes the SSH session.
SSHSessionCloser io.Closer `json:"-"`
}
InstallerCfg is the configuration for installing a service.
type MacvlanOpts ¶
type NetworkOpts ¶
type NetworkOpts struct {
Interfaces string
Tailscale TailscaleOpts
Macvlan MacvlanOpts
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an SSH server that handles exec commands and SFTP subsystem requests. It listens on a specified address and uses the provided SSH server configuration. The server can be configured with a CmdHandlerFunc to handle exec commands and a PutHandlerFunc to handle SFTP PUT requests.
func NewUnstartedServer ¶
NewUnstartedServer creates a new Server instance with the provided configuration but does not start it.
func (*Server) AddEventListener ¶
func (*Server) DockerComposeStatus ¶
func (s *Server) DockerComposeStatus(ns string) (svc.DockerComposeStatus, error)
DockerComposeStatus returns the statuses of the containers for the given service.
func (*Server) DockerComposeStatuses ¶
func (s *Server) DockerComposeStatuses() (map[string]svc.DockerComposeStatus, error)
DockerComposeStatuses returns the status of all Docker services. The keys are the service names and the values are the statuses. Possible statuses are svc.StatusRunning, svc.StatusStopped, and svc.StatusUnknown.
func (*Server) IsServiceRunning ¶
IsServiceRunning returns whether the service with the given name is running. If this is a Docker service, it will return true if any of the containers are running.
func (*Server) NewInstaller ¶
func (s *Server) NewInstaller(cfg InstallerCfg) (*Installer, error)
NewInstaller returns a new SystemdInstaller for the given service name. The binary will be stored in the service's bin directory and installed as a service when closed.
func (*Server) PublishEvent ¶
func (*Server) RemoveEventListener ¶
func (*Server) RemoveService ¶
RemoveService checks if service is stopped, removes the service directory from the filesystem, and removes the service from the database.
func (*Server) SSHHandler ¶
func (*Server) ServeInternalRegistry ¶
func (*Server) ServeSSH ¶
ServeSSH starts the server and listens for incoming connections. It blocks until an error occurs.
func (*Server) Start ¶
func (s *Server) Start()
Start starts the server. It panics if the server is already started.
func (*Server) SystemdStatus ¶
SystemdStatus returns the status of the service with the given name. Possible statuses are svc.StatusRunning, svc.StatusStopped, and svc.StatusUnknown.
func (*Server) SystemdStatuses ¶
SystemdStatuses returns the status of all systemd services. The keys are the service names and the values are the statuses. Possible statuses are svc.StatusRunning, svc.StatusStopped, and svc.StatusUnknown.
type ServerInfo ¶
type ServerInfo struct {
Version string `json:"version"`
GOOS string `json:"goos"`
GOARCH string `json:"goarch"`
}
func GetInfo ¶
func GetInfo() ServerInfo
type ServiceDataType ¶
type ServiceDataType string
func ServiceDataTypeFromServiceType ¶
func ServiceDataTypeFromServiceType(st db.ServiceType) ServiceDataType
func ServiceDataTypeFromUnitType ¶
func ServiceDataTypeFromUnitType(unitType string) ServiceDataType
type ServiceEnabler ¶
ServiceEnabler is an interface extension for services that can be enabled and disabled.
type ServiceRunner ¶
type ServiceRunner interface {
SetNewCmd(func(string, ...string) *exec.Cmd)
Start() error
Stop() error
Restart() error
Logs(opts *svc.LogOptions) error
Remove() error
}
ServiceRunner is an interface for the minimal set of methods required to manage a service.
type ServiceStatusData ¶
type ServiceStatusData struct {
ServiceName string `json:"serviceName"`
ServiceType ServiceDataType `json:"serviceType"`
ComponentStatus []ComponentStatusData `json:"components"`
}