MCPcopy Index your code
hub / github.com/coder/coder / New

Function New

agent/agentscripts/agentscripts.go:62–77  ·  view source on GitHub ↗

New creates a runner for the provided scripts.

(opts Options)

Source from the content-addressed store, hash-verified

60
61// New creates a runner for the provided scripts.
62func New(opts Options) *Runner {
63 cronCtx, cronCtxCancel := context.WithCancel(context.Background())
64 return &Runner{
65 Options: opts,
66 cronCtx: cronCtx,
67 cronCtxCancel: cronCtxCancel,
68 cron: cron.New(cron.WithParser(parser)),
69 closed: make(chan struct{}),
70 dataDir: filepath.Join(opts.DataDirBase, "coder-script-data"),
71 scriptsExecuted: prometheus.NewCounterVec(prometheus.CounterOpts{
72 Namespace: "agent",
73 Subsystem: "scripts",
74 Name: "executed_total",
75 }, []string{"success"}),
76 }
77}
78
79type ScriptCompletedFunc func(context.Context, *proto.WorkspaceAgentScriptCompletedRequest) (*proto.WorkspaceAgentScriptCompletedResponse, error)
80

Callers 3

initMethod · 0.92
TestCronCloseFunction · 0.92
setupFunction · 0.92

Calls 1

NewMethod · 0.65

Tested by 2

TestCronCloseFunction · 0.74
setupFunction · 0.74