s6

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package s6 models s6 service directories: the unit of supervision under an s6-svscan scan dir (in winkit's WSL distro, /etc/s6/services). A Service can be loaded from a directory laid out like a scan dir entry, materialized back to disk, or flattened into build-context file maps.

The package is deliberately free of wsl/docker specifics so other consumers (devcell's fragment replacement) can import it directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// Name is the directory name under the scan dir.
	Name string
	// Run is the run script content. s6-supervise execve()s it directly,
	// so it must start with a #! interpreter line.
	Run string
	// Files are extra files relative to the service dir (finish, data/…).
	// The key "run" is reserved for Run.
	Files map[string][]byte
}

Service is one s6 service directory for an s6-svscan scan dir.

func FromDir

func FromDir(name, dir string) (Service, error)

FromDir loads one service from a directory laid out like a scan dir entry: it must contain a "run" file; everything else becomes Files.

func FromFS

func FromFS(fsys fs.FS, root, name string) (Service, error)

FromFS loads a single service dir rooted at root within fsys (the fs.FS counterpart of FromDir, used for embedded catalogs).

func LoadDir

func LoadDir(dir string) ([]Service, error)

LoadDir loads every subdirectory of dir as a Service — dir has the on-disk shape of an s6 scan dir. Non-directory entries and an empty dir are errors (a scan dir with stray files is almost always a misconfigured path).

func LoadFS

func LoadFS(fsys fs.FS, root string) ([]Service, error)

LoadFS is LoadDir over an fs.FS rooted at root, for embedded catalogs. Services are returned sorted by name.

func (Service) ContextFiles

func (s Service) ContextFiles(prefix string) (map[string][]byte, error)

ContextFiles flattens the service into file-map entries keyed by prefix + "<name>/<rel>" (slash-separated), the shape of a docker build context map. Run is normalized to LF line endings.

func (Service) Validate

func (s Service) Validate() error

Validate checks the service is materializable and supervisable.

func (Service) WriteDir

func (s Service) WriteDir(scanDir string) error

WriteDir materializes the service under scanDir: run (and a top-level finish, if present) are written 0755, everything else 0644. Intended for runtime scan dirs and tests; docker builds go through ContextFiles.

Jump to

Keyboard shortcuts

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