diff --git a/cmd/gogs/web.go b/cmd/gogs/web.go index c077e033e..858e7fdca 100644 --- a/cmd/gogs/web.go +++ b/cmd/gogs/web.go @@ -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) } diff --git a/internal/embeddedpg/embeddedpg.go b/internal/embeddedpg/embeddedpg.go index 4cdf5f7f1..28feb7704 100644 --- a/internal/embeddedpg/embeddedpg.go +++ b/internal/embeddedpg/embeddedpg.go @@ -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)