feat(startup): print service banner after listener ready

This commit is contained in:
ryan
2026-07-13 15:56:30 +08:00
parent 9cac25696a
commit 08fac67f2a
10 changed files with 198 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