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

Commitf4afd17

Browse files
committed
only use a custom cache dir for built-in postgres when running with --ephemeral
1 parentbf59464 commitf4afd17

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

‎cli/server.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,16 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
413413
if!vals.InMemoryDatabase&&vals.PostgresURL=="" {
414414
varcloseFuncfunc()error
415415
cliui.Infof(inv.Stdout,"Using built-in PostgreSQL (%s)",config.PostgresPath())
416-
pgURL,closeFunc,err:=startBuiltinPostgres(ctx,config,logger,cacheDir)
416+
customPostgresCacheDir:=""
417+
// By default, built-in PostgreSQL will use the Coder root directory
418+
// for its cache. However, when a deployment is ephemeral, the root
419+
// directory is wiped clean on shutdown, defeating the purpose of using
420+
// it as a cache. So here we use a cache directory that will not get
421+
// removed on restart.
422+
ifvals.EphemeralDeployment.Value() {
423+
customPostgresCacheDir=cacheDir
424+
}
425+
pgURL,closeFunc,err:=startBuiltinPostgres(ctx,config,logger,customPostgresCacheDir)
417426
iferr!=nil {
418427
returnerr
419428
}
@@ -1964,7 +1973,7 @@ func embeddedPostgresURL(cfg config.Root) (string, error) {
19641973
returnfmt.Sprintf("postgres://coder@localhost:%s/coder?sslmode=disable&password=%s",pgPort,pgPassword),nil
19651974
}
19661975

1967-
funcstartBuiltinPostgres(ctx context.Context,cfg config.Root,logger slog.Logger,cacheDirstring) (string,func()error,error) {
1976+
funcstartBuiltinPostgres(ctx context.Context,cfg config.Root,logger slog.Logger,customCacheDirstring) (string,func()error,error) {
19681977
usr,err:=user.Current()
19691978
iferr!=nil {
19701979
return"",nil,err
@@ -1992,8 +2001,8 @@ func startBuiltinPostgres(ctx context.Context, cfg config.Root, logger slog.Logg
19922001
}
19932002

19942003
cachePath:=filepath.Join(cfg.PostgresPath(),"cache")
1995-
ifcacheDir!="" {
1996-
cachePath=filepath.Join(cacheDir,"postgres")
2004+
ifcustomCacheDir!="" {
2005+
cachePath=filepath.Join(customCacheDir,"postgres")
19972006
}
19982007
stdlibLogger:=slog.Stdlib(ctx,logger.Named("postgres"),slog.LevelDebug)
19992008
ep:=embeddedpostgres.NewDatabase(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp