supervise

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: 15 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 supervise runs a server process in the foreground and gives every platform the same controls: a console socket for sending commands to the server's stdin, a clean stop that types the server's own stop command before resorting to signals, and a log file.

Service managers (systemd, Windows services, launchd) and containers all run `anyserve run <name>`, which ends up here, so stopping behaves the same everywhere.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, o Options) error

Run starts the server and blocks until it exits. A SIGINT or SIGTERM (or ctx being cancelled) triggers a clean stop.

func Send

func Send(socket, line string) error

Send writes one console command to a running server's socket.

Types

type Options

type Options struct {
	Command string
	Args    []string
	Dir     string
	Env     []string
	// StopCommand is written to stdin to stop the server cleanly.
	StopCommand string
	// StopFunc, if set, sends StopCommand another way (such as RCON)
	// instead of writing it to stdin.
	StopFunc    func() error
	StopTimeout time.Duration
	// Socket is the console socket path. Empty disables it.
	Socket string
	// LogDir receives server.log. Empty disables the log file.
	LogDir string
	// Stdout receives the server's output as well (e.g. the journal).
	Stdout io.Writer
	// Log receives the supervisor's own messages.
	Log func(format string, a ...any)
}

Options configures one supervised run.

Jump to

Keyboard shortcuts

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