background

package
v0.0.0-...-0f74808 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package background contains an abstraction for running processes in the background.

Index

Constants

This section is empty.

Variables

View Source
var ErrUserKilled = xerrors.Errorf("daemon killed by user")

Functions

This section is empty.

Types

type Process

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

Process is an abstraction for running a command as a background process.

func New

func New(ctx context.Context, log slog.Logger, cmd string, args ...string) *Process

New returns an instantiated daemon.

func (*Process) Restart

func (d *Process) Restart(ctx context.Context, cmd string, args ...string) error

Restart kill the running process and reruns the command with the updated cmd and args.

func (*Process) Run

func (d *Process) Run() <-chan error

Run runs the command and waits for it to exit. It is a convenience function that combines both Start() and Wait().

func (*Process) Start

func (d *Process) Start() error

Start starts the daemon. It functions akin to ox/exec.Command.Start().

func (*Process) Wait

func (d *Process) Wait() <-chan error

Wait waits for the process to exit, returning the error on the provided channel.

Jump to

Keyboard shortcuts

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