New creates a runner for the provided scripts.
(opts Options)
| 60 | |
| 61 | // New creates a runner for the provided scripts. |
| 62 | func 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 | |
| 79 | type ScriptCompletedFunc func(context.Context, *proto.WorkspaceAgentScriptCompletedRequest) (*proto.WorkspaceAgentScriptCompletedResponse, error) |
| 80 |