service

package
v0.3.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package service installs and runs services (game servers, bots) in Docker, following Pterodactyl/Wings conventions so official eggs and yolks images work unchanged: data in /home/container (uid 988), install script in a separate container with the data mounted at /mnt/server, STARTUP in the environment, and stop via console command or signal.

Index

Constants

View Source
const ContainerUID = containerUID

ContainerUID owns service files (the yolks "container" user).

View Source
const ContainerUser = "988:988"

ContainerUser is the uid:gid services run as; yolks images expect user "container" (988).

Variables

View Source
var ErrNotRunning = errors.New("server is not running")

ErrNotRunning is returned for console commands while the server is stopped.

View Source
var ErrOutside = errors.New("path is outside the server directory")

ErrOutside is returned for paths that would leave the data directory.

Functions

This section is empty.

Types

type Docker

type Docker interface {
	EnsureImage(ctx context.Context, ref string, progress func(string)) error
	CreateContainer(ctx context.Context, name string, cfg docker.ContainerConfig) (string, error)
	StartContainer(ctx context.Context, id string) error
	KillContainer(ctx context.Context, id, signal string) error
	RemoveContainer(ctx context.Context, id string) error
	InspectContainer(ctx context.Context, id string) (docker.ContainerState, error)
	WaitContainer(ctx context.Context, id string) (int, error)
	Attach(ctx context.Context, id string) (io.ReadWriteCloser, error)
	Stats(ctx context.Context, id string) (docker.StatsSample, error)
	BridgeGateway(ctx context.Context) (string, error)
}

Docker is the subset of the Docker client the manager uses (an interface for tests).

type Manager

type Manager struct {

	// Websites lets file operations and SFTP reach website homes (set when web hosting
	// is available): directory, owner and quota check of a website ID.
	Websites interface {
		Lookup(id string) (dir string, uid int, ok bool)
		CheckQuota(id string, n int64) error
	}
	// contains filtered or unexported fields
}

Manager owns every service on this node.

func New

func New(d Docker, dataDir string, emit func(typ string, data any), logger *slog.Logger) *Manager

New returns a manager storing data under dataDir. emit sends events to the panel (service.state, console.line, stats); it must not block for long.

func (*Manager) Backlog

func (m *Manager) Backlog(id string) ([]string, error)

Backlog returns recent console output.

func (*Manager) CheckQuota

func (m *Manager) CheckQuota(id string, n int64) error

CheckQuota refuses writes of n more bytes once the service is at its disk limit.

func (*Manager) Command

func (m *Manager) Command(id, command string) error

Command writes a line to the server's stdin.

func (*Manager) Create

func (m *Manager) Create(spec proto.ServiceSpec, reinstall bool) error

Create stores a new (or updated) spec and installs the service in the background.

func (*Manager) Delete

func (m *Manager) Delete(id string) error

Delete stops the service and removes its containers, data and spec.

func (*Manager) DeleteFiles

func (m *Manager) DeleteFiles(id string, paths []string) error

DeleteFiles removes files and directories. The data directory itself cannot be deleted.

func (*Manager) ListFiles

func (m *Manager) ListFiles(id, dir string) (proto.FileList, error)

ListFiles returns a directory's entries, directories first.

func (*Manager) Load

func (m *Manager) Load(ctx context.Context) error

Load restores services saved on disk and reattaches to containers that are still running.

func (*Manager) MakeDir

func (m *Manager) MakeDir(id, dir string) error

MakeDir creates a directory (and its parents).

func (*Manager) Output

func (m *Manager) Output(id string) []string

Output returns the most recent console lines (used for crash details now, the console later).

func (*Manager) Power

func (m *Manager) Power(req proto.PowerRequest) error

Power handles start, stop, restart and kill. It returns once the action is under way.

func (*Manager) ReadFile

func (m *Manager) ReadFile(req proto.FileRead) (proto.FileChunk, error)

ReadFile returns up to length bytes of a regular file starting at offset.

func (*Manager) RenameFile

func (m *Manager) RenameFile(id, from, to string, overwrite bool) error

RenameFile moves a file or directory; the destination must not exist.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run sends batched console output and enforces disk limits until ctx ends. Start it once next to the panel link.

func (*Manager) ServiceDir

func (m *Manager) ServiceDir(id string) (string, int, error)

ServiceDir returns the directory and file owner of a service or website (SFTP sessions).

func (*Manager) States

func (m *Manager) States() []proto.ServiceState

States lists every service and its state (sent in hello).

func (*Manager) Watch

func (m *Manager) Watch(id string, on bool) error

Watch turns streaming of console lines and stats for a service on or off. The panel subscribes while at least one person has the console open.

func (*Manager) WriteFile

func (m *Manager) WriteFile(w proto.FileWrite) error

WriteFile replaces (or appends to) a regular file, creating parent directories. Files are owned by the container user so the server can use them.

Jump to

Keyboard shortcuts

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