Documentation
¶
Index ¶
- Variables
- type ExecuteOption
- type InitOption
- type Options
- type Runner
- func (r *Runner) Close() error
- func (r *Runner) DataDir() string
- func (r *Runner) Execute(ctx context.Context, option ExecuteOption) error
- func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript, scriptCompleted ScriptCompletedFunc, ...) error
- func (r *Runner) RegisterMetrics(reg prometheus.Registerer)
- func (r *Runner) ScriptBinDir() string
- func (r *Runner) StartCron()
- type ScriptCompletedFunc
- type ScriptLogger
Constants ¶
This section is empty.
Variables ¶
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 ExecuteOption ¶ added in v2.16.0
type ExecuteOption int
ExecuteOption describes what scripts we want to execute.
const ( ExecuteAllScripts ExecuteOption = iota ExecuteStartScripts ExecutePostStartScripts ExecuteStopScripts ExecuteCronScripts )
ExecuteOption enums.
type InitOption ¶ added in v2.21.0
type InitOption func(*Runner)
InitOption describes an option for the runner initialization.
func WithPostStartScripts ¶ added in v2.21.0
func WithPostStartScripts(scripts ...codersdk.WorkspaceAgentScript) InitOption
WithPostStartScripts adds scripts that should be run after the workspace start scripts but before the workspace is marked as started.
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 (*Runner) DataDir ¶ added in v2.9.0
DataDir returns the directory where scripts data is stored.
func (*Runner) Execute ¶
func (r *Runner) Execute(ctx context.Context, option ExecuteOption) error
Execute runs a set of scripts according to a filter.
func (*Runner) Init ¶
func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript, scriptCompleted ScriptCompletedFunc, opts ...InitOption) 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
ScriptBinDir returns the directory where scripts can store executable binaries.
type ScriptCompletedFunc ¶ added in v2.16.0
type ScriptCompletedFunc func(context.Context, *proto.WorkspaceAgentScriptCompletedRequest) (*proto.WorkspaceAgentScriptCompletedResponse, error)