fix(gateway): log startup errors before exit
This commit is contained in:
parent
6ce0306c66
commit
e08d1c4975
1 changed files with 12 additions and 1 deletions
|
|
@ -111,7 +111,7 @@ func (p *startupBlockedProvider) GetDefaultModel() string {
|
|||
}
|
||||
|
||||
// Run starts the gateway runtime using the configuration loaded from configPath.
|
||||
func Run(debug bool, homePath, configPath string, allowEmptyStartup bool) error {
|
||||
func Run(debug bool, homePath, configPath string, allowEmptyStartup bool) (runErr error) {
|
||||
panicPath := filepath.Join(homePath, logPath, panicFile)
|
||||
panicFunc, err := logger.InitPanic(panicPath)
|
||||
if err != nil {
|
||||
|
|
@ -129,6 +129,17 @@ func Run(debug bool, homePath, configPath string, allowEmptyStartup bool) error
|
|||
} else {
|
||||
logger.SetLevelFromString(config.ResolveGatewayLogLevel(configPath))
|
||||
}
|
||||
defer func() {
|
||||
if runErr != nil {
|
||||
logger.ErrorCF("gateway", "Gateway startup failed", map[string]any{
|
||||
"config_path": configPath,
|
||||
"error": runErr.Error(),
|
||||
"home_path": homePath,
|
||||
"allow_empty": allowEmptyStartup,
|
||||
"debug": debug,
|
||||
})
|
||||
}
|
||||
}()
|
||||
|
||||
cfg, err := config.LoadConfig(configPath)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue