mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
feat(setup): add web-based first-run configuration wizard
When config.json is missing, Erupe now launches a temporary HTTP server on port 8080 serving a guided setup wizard instead of exiting with a cryptic error. The wizard walks users through database connection, schema initialization (pg_restore + SQL migrations), and server settings, then writes config.json and continues normal startup without restart.
This commit is contained in:
18
main.go
18
main.go
@@ -16,6 +16,7 @@ import (
|
||||
"erupe-ce/server/channelserver"
|
||||
"erupe-ce/server/discordbot"
|
||||
"erupe-ce/server/entranceserver"
|
||||
"erupe-ce/server/setup"
|
||||
"erupe-ce/server/signserver"
|
||||
"strings"
|
||||
|
||||
@@ -79,11 +80,18 @@ func main() {
|
||||
|
||||
config, cfgErr := cfg.LoadConfig()
|
||||
if cfgErr != nil {
|
||||
fmt.Println("\nFailed to start Erupe:\n" + fmt.Sprintf("Failed to load config: %s", cfgErr.Error()))
|
||||
go wait()
|
||||
fmt.Println("\nPress Enter/Return to exit...")
|
||||
_, _ = fmt.Scanln()
|
||||
os.Exit(0)
|
||||
if _, err := os.Stat("config.json"); os.IsNotExist(err) {
|
||||
logger.Info("No config.json found, launching setup wizard")
|
||||
if err := setup.Run(logger.Named("setup"), 8080); err != nil {
|
||||
logger.Fatal("Setup wizard failed", zap.Error(err))
|
||||
}
|
||||
config, cfgErr = cfg.LoadConfig()
|
||||
if cfgErr != nil {
|
||||
logger.Fatal("Config still invalid after setup", zap.Error(cfgErr))
|
||||
}
|
||||
} else {
|
||||
preventClose(config, fmt.Sprintf("Failed to load config: %s", cfgErr.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info(fmt.Sprintf("Starting Erupe (9.3b-%s)", Commit()))
|
||||
|
||||
Reference in New Issue
Block a user