agentscripts

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeout is returned when a script times out.
	ErrTimeout = xerrors.New("script timed out")
	// ErrOutputPipesOpen is returned when a script exits leaving the output
	// pipe(s) (stdout, stderr) open. This happens because we set WaitDelay on
	// the command, which gives us two things:
	//
	// 1. The ability to ensure that a script exits (this is important for e.g.
	//    blocking login, and avoiding doing so indefinitely)
	// 2. Improved command cancellation on timeout
	ErrOutputPipesOpen = xerrors.New("script exited without closing output pipes")
)

Functions

This section is empty.

Types

type Options

type Options struct {
	DataDirBase     string
	LogDir          string
	Logger          slog.Logger
	SSHServer       *agentssh.Server
	Filesystem      afero.Fs
	GetScriptLogger func(logSourceID uuid.UUID) ScriptLogger
}

Options are a set of options for the runner.

type Runner

type Runner struct {
	Options
	// contains filtered or unexported fields
}

func New

func New(opts Options) *Runner

New creates a runner for the provided scripts.

func (*Runner) Close

func (r *Runner) Close() error

func (*Runner) DataDir added in v2.9.0

func (r *Runner) DataDir() string

DataDir returns the directory where scripts data is stored.

func (*Runner) Execute

func (r *Runner) Execute(ctx context.Context, filter func(script codersdk.WorkspaceAgentScript) bool) error

Execute runs a set of scripts according to a filter.

func (*Runner) Init

func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript) error

Init initializes the runner with the provided scripts. It also schedules any scripts that have a schedule. This function must be called before Execute.

func (*Runner) RegisterMetrics added in v2.5.1

func (r *Runner) RegisterMetrics(reg prometheus.Registerer)

func (*Runner) ScriptBinDir added in v2.9.0

func (r *Runner) ScriptBinDir() string

ScriptBinDir returns the directory where scripts can store executable binaries.

func (*Runner) StartCron

func (r *Runner) StartCron()

StartCron starts the cron scheduler. This is done async to allow for the caller to execute scripts prior.

type ScriptLogger added in v2.9.0

type ScriptLogger interface {
	Send(ctx context.Context, log ...agentsdk.Log) error
	Flush(context.Context) error
}

Jump to

Keyboard shortcuts

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