mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
implement panic log for gateway and launcher
add file logger to gateway ref issue: #1734 Signed-off-by: Cytown <cytown@gmail.com>
This commit is contained in:
+17
-1
@@ -47,6 +47,10 @@ const (
|
||||
serviceShutdownTimeout = 30 * time.Second
|
||||
providerReloadTimeout = 30 * time.Second
|
||||
gracefulShutdownTimeout = 15 * time.Second
|
||||
|
||||
logPath = "logs"
|
||||
panicFile = "gateway_panic.log"
|
||||
logFile = "gateway.log"
|
||||
)
|
||||
|
||||
type services struct {
|
||||
@@ -79,7 +83,19 @@ func (p *startupBlockedProvider) GetDefaultModel() string {
|
||||
}
|
||||
|
||||
// Run starts the gateway runtime using the configuration loaded from configPath.
|
||||
func Run(debug bool, configPath string, allowEmptyStartup bool) error {
|
||||
func Run(debug bool, homePath, configPath string, allowEmptyStartup bool) error {
|
||||
panicPath := filepath.Join(homePath, logPath, panicFile)
|
||||
panicFunc, err := logger.InitPanic(panicPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error initializing panic log: %w", err)
|
||||
}
|
||||
defer panicFunc()
|
||||
|
||||
if err = logger.EnableFileLogging(filepath.Join(homePath, logPath, logFile)); err != nil {
|
||||
panic(fmt.Sprintf("error enabling file logging: %v", err))
|
||||
}
|
||||
defer logger.DisableFileLogging()
|
||||
|
||||
cfg, err := config.LoadConfig(configPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error loading config: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user