mirror of
https://github.com/gogs/gogs.git
synced 2026-02-27 08:40:54 +01:00
Fix embedded Postgres configuration and initialization order
Co-authored-by: unknwon <2946214+unknwon@users.noreply.github.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user