fix(tui): update with review

This commit is contained in:
lhpqaq
2026-02-16 00:24:25 +08:00
parent 0a2555b0f3
commit 2c8821891c
6 changed files with 197 additions and 163 deletions

View File

@@ -511,22 +511,22 @@ func main() {
password = localMgmtPassword
}
// Ensure management routes are registered (secret-key must be set)
if cfg.RemoteManagement.SecretKey == "" {
cfg.RemoteManagement.SecretKey = "$tui-placeholder$"
}
// Start server in background
cancel, done := cmd.StartServiceBackground(cfg, configFilePath, password)
// Wait for server to be ready by polling management API
// Wait for server to be ready by polling management API with exponential backoff
{
client := tui.NewClient(cfg.Port, password)
for i := 0; i < 50; i++ {
time.Sleep(100 * time.Millisecond)
backoff := 100 * time.Millisecond
// Try for up to ~10-15 seconds
for i := 0; i < 30; i++ {
if _, err := client.GetConfig(); err == nil {
break
}
time.Sleep(backoff)
if backoff < 1*time.Second {
backoff = time.Duration(float64(backoff) * 1.5)
}
}
}