Fix embedded Postgres configuration and initialization order

Co-authored-by: unknwon <2946214+unknwon@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-06 01:48:00 +00:00
parent 74d4d9a262
commit 76f3497e3b
2 changed files with 10 additions and 4 deletions

View File

@@ -162,6 +162,13 @@ func newMacaron() *macaron.Macaron {
}
func runWeb(c *cli.Context) error {
// Initialize configuration first to get WorkDir
err := conf.Init(c.String("config"))
if err != nil {
log.Fatal("Failed to initialize configuration: %v", err)
}
conf.InitLogging(false)
var localPg *embeddedpg.LocalPostgres
if c.Bool("embedded-postgres") {
@@ -177,7 +184,7 @@ func runWeb(c *cli.Context) error {
localPg.ConfigureGlobalDatabase()
}
err := route.GlobalInit(c.String("config"))
err = route.GlobalInit(c.String("config"))
if err != nil {
log.Fatal("Failed to initialize application: %v", err)
}

View File

@@ -38,7 +38,9 @@ func Initialize(workDir string) *LocalPostgres {
// Launch starts the embedded PostgreSQL server and blocks until ready.
func (pg *LocalPostgres) Launch() error {
log.Info("Launching local PostgreSQL server...")
log.Trace("Base directory: %s", pg.baseDir)
// Create base directory
if err := os.MkdirAll(pg.baseDir, 0o700); err != nil {
return errors.Wrap(err, "mkdir local postgres base")
}
@@ -49,9 +51,6 @@ func (pg *LocalPostgres) Launch() error {
Database(pg.database).
Port(pg.tcpPort).
DataPath(pg.baseDir).
RuntimePath(filepath.Join(pg.baseDir, "rt")).
BinariesPath(filepath.Join(pg.baseDir, "bin")).
CachePath(filepath.Join(pg.baseDir, "dl")).
StartTimeout(45 * time.Second).
Logger(os.Stderr)