Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd0f8a3

Browse files
committed
make lifecycle executor spawn a new goroutine automatically
1 parentf6388b4 commitfd0f8a3

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

‎cli/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func server() *cobra.Command {
347347
lifecyclePoller:=time.NewTicker(time.Minute)
348348
deferlifecyclePoller.Stop()
349349
lifecycleExecutor:=executor.New(cmd.Context(),options.Database,logger,lifecyclePoller.C)
350-
golifecycleExecutor.Run()
350+
lifecycleExecutor.Run()
351351

352352
// Because the graceful shutdown includes cleaning up workspaces in dev mode, we're
353353
// going to make it harder to accidentally skip the graceful shutdown by hitting ctrl+c

‎coderd/coderdtest/coderdtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func New(t *testing.T, options *Options) *codersdk.Client {
110110
slogtest.Make(t,nil).Named("lifecycle.executor").Leveled(slog.LevelDebug),
111111
options.LifecycleTicker,
112112
)
113-
golifecycleExecutor.Run()
113+
lifecycleExecutor.Run()
114114

115115
srv:=httptest.NewUnstartedServer(nil)
116116
srv.Config.BaseContext=func(_ net.Listener) context.Context {

‎coderd/lifecycle/executor/lifecycle_executor.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ func New(ctx context.Context, db database.Store, log slog.Logger, tick <-chan ti
3838
// tick from its channel. It will stop when its context is Done, or when
3939
// its channel is closed.
4040
func (e*Executor)Run() {
41-
fort:=rangee.tick {
42-
iferr:=e.runOnce(t);err!=nil {
43-
e.log.Error(e.ctx,"error running once",slog.Error(err))
41+
gofunc() {
42+
fort:=rangee.tick {
43+
iferr:=e.runOnce(t);err!=nil {
44+
e.log.Error(e.ctx,"error running once",slog.Error(err))
45+
}
4446
}
45-
}
47+
}()
4648
}
4749

4850
func (e*Executor)runOnce(t time.Time)error {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp