diff --git a/cmd/bbgo-lorca/main.go b/cmd/bbgo-lorca/main.go index 170c1dd4c..bcaf598fd 100644 --- a/cmd/bbgo-lorca/main.go +++ b/cmd/bbgo-lorca/main.go @@ -7,6 +7,7 @@ import ( "os/signal" "path/filepath" "runtime" + time2 "time" "github.com/joho/godotenv" "github.com/zserge/lorca" @@ -135,7 +136,7 @@ func main() { }() log.Infof("pinging the server at %s", baseURL) - server.PingUntil(ctx, baseURL, func() { + server.PingUntil(ctx, time2.Second, baseURL, func() { log.Infof("got pong, loading base url %s to ui...", baseURL) if err := ui.Load(baseURL); err != nil { diff --git a/pkg/server/ping.go b/pkg/server/ping.go index ec56b55a1..39de99b4d 100644 --- a/pkg/server/ping.go +++ b/pkg/server/ping.go @@ -7,11 +7,11 @@ import ( "github.com/sirupsen/logrus" ) -func PingUntil(ctx context.Context, baseURL string, callback func()) { +func PingUntil(ctx context.Context, interval time.Duration, baseURL string, callback func()) { pingURL := baseURL + "/api/ping" timeout := time.NewTimer(3 * time.Minute) - ticker := time.NewTicker(time.Second) + ticker := time.NewTicker(interval) defer ticker.Stop() for { @@ -37,7 +37,7 @@ func PingUntil(ctx context.Context, baseURL string, callback func()) { func pingAndOpenURL(ctx context.Context, baseURL string) { setupURL := baseURL + "/setup" - go PingUntil(ctx, baseURL, func() { + go PingUntil(ctx, time.Second, baseURL, func() { if err := openURL(setupURL); err != nil { logrus.WithError(err).Errorf("can not call open command to open the web page") }