mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 01:01:56 +00:00
pull out ping interval parameter
This commit is contained in:
parent
3629a1f5a2
commit
f2978fa89c
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user