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
- Variables
- type Docker
- type Manager
- func (m *Manager) Backlog(id string) ([]string, error)
- func (m *Manager) CheckQuota(id string, n int64) error
- func (m *Manager) Command(id, command string) error
- func (m *Manager) Create(spec proto.ServiceSpec, reinstall bool) error
- func (m *Manager) Delete(id string) error
- func (m *Manager) DeleteFiles(id string, paths []string) error
- func (m *Manager) ListFiles(id, dir string) (proto.FileList, error)
- func (m *Manager) Load(ctx context.Context) error
- func (m *Manager) MakeDir(id, dir string) error
- func (m *Manager) Output(id string) []string
- func (m *Manager) Power(req proto.PowerRequest) error
- func (m *Manager) ReadFile(req proto.FileRead) (proto.FileChunk, error)
- func (m *Manager) RenameFile(id, from, to string, overwrite bool) error
- func (m *Manager) Run(ctx context.Context)
- func (m *Manager) ServiceDir(id string) (string, int, error)
- func (m *Manager) States() []proto.ServiceState
- func (m *Manager) Watch(id string, on bool) error
- func (m *Manager) WriteFile(w proto.FileWrite) error
Constants ¶
const ContainerUID = containerUID
ContainerUID owns service files (the yolks "container" user).
const ContainerUser = "988:988"
ContainerUser is the uid:gid services run as; yolks images expect user "container" (988).
Variables ¶
var ErrNotRunning = errors.New("server is not running")
ErrNotRunning is returned for console commands while the server is stopped.
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 ¶
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) CheckQuota ¶
CheckQuota refuses writes of n more bytes once the service is at its disk limit.
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) DeleteFiles ¶
DeleteFiles removes files and directories. The data directory itself cannot be deleted.
func (*Manager) Load ¶
Load restores services saved on disk and reattaches to containers that are still running.
func (*Manager) Output ¶
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 ¶
ReadFile returns up to length bytes of a regular file starting at offset.
func (*Manager) RenameFile ¶
RenameFile moves a file or directory; the destination must not exist.
func (*Manager) Run ¶
Run sends batched console output and enforces disk limits until ctx ends. Start it once next to the panel link.
func (*Manager) ServiceDir ¶
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).