This PR adds a package lifecycle and an Executor implementation that attempts to schedule a build of workspaces with autostart configured.
- lifecycle.Executor takes a chan time.Time in its constructor (e.g. time.Tick(time.Minute))
- Whenever a value is received from this channel, it executes one iteration of looping through the workspaces and triggering lifecycle operations.
- When the context passed to the executor is Done, it exits.
- Only workspaces that meet the following criteria will have a lifecycle operation applied to them:
- Workspace has a valid and non-empty autostart or autostop schedule (either)
- Workspace's last build was successful
- The following transitions will be applied depending on the current workspace state:
- If the workspace is currently running, it will be stopped.
- If the workspace is currently stopped, it will be started.
- Otherwise, nothing will be done.
- Workspace builds will be created with the same parameters and template version as the last successful build (for example, template version)
coderd would fail silently if this was called, because connections
would never drain. HashiCorp's hc-install package broke today,
and we couldn't notice because this was hanging!
* feat: make it harder to skip graceful shutdown accidentally
Signed-off-by: Spike Curtis <spike@coder.com>
* fixup: don't use unbuffered signal channel
Signed-off-by: Spike Curtis <spike@coder.com>
* feat: Generate random admin user password in dev mode
* Add dev mode test with email/pass from env
* Set email/pass for playwright e2e test via cli flags
This removes split ownership for workspaces. They are now
a resource of organizations and have a designated owner,
which is a user.
This enables simple administration for commands like:
- `coder stop ben/dev`
- `coder build logs colin/arch`
or if we decide to allow administrators to access workspaces,
they could even SSH using this syntax: `coder ssh colin/dev`.
Workspace commands will be aliased at the top-level, so
"start" would easily be confused with starting a workspace.
Server seems like a more appropriate name too.