target

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 17 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 target turns an installed instance into a running service on a particular platform: a systemd unit, a Windows service, a launchd agent, a container or a Kubernetes manifest.

Every native target runs the same thing: `anyserve run <name>`, which supervises the server. Targets only decide how that command gets started, restarted and logged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compose

func Compose(in *instance.Instance, d *spec.Definition, uid, gid int) ([]byte, error)

Compose renders the compose file for a stack instance. Exported for tests.

func Default

func Default() string

Default is the native service manager for this OS.

func DockerExec

func DockerExec(in *instance.Instance, service string, command []string, tty bool, stdin io.Reader, stdout, stderr io.Writer) error

DockerExec runs a program inside one of a stack's running containers. With tty set it attaches the terminal, for interactive shells.

func Names

func Names() []string

Names lists every target, sorted.

Types

type Env

type Env struct {
	// Exe is the absolute path of the anyserve binary.
	Exe string
	// Home is set when ANYSERVE_HOME is in use, so services see it too.
	Home string
	Out  io.Writer
}

Env is what a target needs from the caller.

type Status

type Status struct {
	State  string // running, stopped, failed, unknown
	Detail string
}

Status is a target's view of whether an instance is running.

type Target

type Target interface {
	Name() string
	Description() string
	// Available reports whether the target works on this machine, and why
	// not if it doesn't.
	Available() error
	// SupportsService reports whether a service can run on this target.
	SupportsService(d *spec.Definition) error
	// Register creates or refreshes the service for an instance.
	Register(in *instance.Instance, d *spec.Definition, env Env) error
	Unregister(in *instance.Instance) error
	Start(in *instance.Instance) error
	Stop(in *instance.Instance) error
	Status(in *instance.Instance) Status
	// Logs shows recent output, following it if follow is set.
	Logs(in *instance.Instance, lines int, follow bool, out io.Writer) error
}

Target manages instances on one kind of platform.

func All

func All() []Target

All returns every target, sorted by name.

func Get

func Get(name string) (Target, error)

Get returns a target by name.

Jump to

Keyboard shortcuts

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