service

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package service runs the background processes a scenario declares under `services`: a long-lived peer (a TCP server, an API stub) started before the scenario's steps and torn down — with its whole process group — when the scenario ends. It reuses the command runner's tokenization and environment handling so a service spawns identically to a run step.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proc

type Proc struct {
	// contains filtered or unexported fields
}

Proc is a running background service. Stop terminates it and its children.

func Start

func Start(ctx context.Context, svc *spec.Service, workdir string) (*Proc, string, error)

Start spawns svc in workdir and blocks until its readiness probe passes. The returned captured value is the trimmed content of the ready file when Ready.File and Ready.Store are both set (otherwise ""); the caller stores it as ${Ready.Store}. On any error the (partially started) process is stopped before returning.

func (*Proc) Name

func (p *Proc) Name() string

Name returns the service's declared name.

func (*Proc) Output

func (p *Proc) Output() string

Output returns whatever the service has written to stdout/stderr so far. It is used to enrich a readiness failure message.

func (*Proc) Signal added in v0.3.0

func (p *Proc) Signal(name string) error

Signal delivers the named POSIX signal (TERM, INT, HUP, USR1, USR2, KILL) to the service's whole process group (#23), consistent with the teardown kill semantics. Signaling a service that already exited is an error naming the service — a graceful-shutdown spec that signals a dead process is asserting against nothing.

func (*Proc) Stop

func (p *Proc) Stop()

Stop terminates the service's process group: a graceful signal first, then a hard kill if it does not exit within a short grace period. It is safe to call once; subsequent calls are no-ops because the process has already exited.

func (*Proc) WaitExit added in v0.3.0

func (p *Proc) WaitExit(timeout time.Duration) bool

WaitExit blocks until the service's process exits or timeout elapses, reporting whether it exited (#23). The exit is observed through the same done channel Stop uses, so a later teardown Stop is a clean no-op.

Jump to

Keyboard shortcuts

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