feat(startup): print service banner after listener ready

This commit is contained in:
ryan
2026-07-13 15:49:19 +08:00
parent 26be762c3a
commit 6b6c786cfe
11 changed files with 200 additions and 13 deletions
+12 -4
View File
@@ -39,8 +39,7 @@ var rootCmd = &cobra.Command{
})
},
PreRun: func(_ *cobra.Command, _ []string) {
migrator.Migrate()
migrator.MigrateClickHouse()
runMigrations()
},
PersistentPostRun: func(_ *cobra.Command, _ []string) {
shutdownTraceProvider()
@@ -51,6 +50,16 @@ var rootCmd = &cobra.Command{
},
}
var latestMigrationState struct {
relationalDB migrator.Report
clickHouseDB migrator.Report
}
func runMigrations() {
latestMigrationState.relationalDB = migrator.Migrate()
latestMigrationState.clickHouseDB = migrator.MigrateClickHouse()
}
func shutdownTraceProvider() {
ctx, cancel := context.WithTimeout(context.Background(), traceShutdownTimeout)
defer cancel()
@@ -63,8 +72,7 @@ func init() {
// 1. 为需要迁移的子命令动态绑定原先 rootCmd.PreRun 拥有的数据库迁移行为
migratePreRun := func(_ *cobra.Command, _ []string) {
migrator.Migrate()
migrator.MigrateClickHouse()
runMigrations()
}
allCmd.PreRun = migratePreRun
apiCmd.PreRun = migratePreRun