mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 02:53:50 +00:00
pull out ping interval parameter
This commit is contained in:
parent
3629a1f5a2
commit
f2978fa89c
|
@ -7,6 +7,7 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
time2 "time"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/zserge/lorca"
|
"github.com/zserge/lorca"
|
||||||
|
@ -135,7 +136,7 @@ func main() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.Infof("pinging the server at %s", baseURL)
|
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)
|
log.Infof("got pong, loading base url %s to ui...", baseURL)
|
||||||
|
|
||||||
if err := ui.Load(baseURL); err != nil {
|
if err := ui.Load(baseURL); err != nil {
|
||||||
|
|
|
@ -7,11 +7,11 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"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"
|
pingURL := baseURL + "/api/ping"
|
||||||
timeout := time.NewTimer(3 * time.Minute)
|
timeout := time.NewTimer(3 * time.Minute)
|
||||||
|
|
||||||
ticker := time.NewTicker(time.Second)
|
ticker := time.NewTicker(interval)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -37,7 +37,7 @@ func PingUntil(ctx context.Context, baseURL string, callback func()) {
|
||||||
|
|
||||||
func pingAndOpenURL(ctx context.Context, baseURL string) {
|
func pingAndOpenURL(ctx context.Context, baseURL string) {
|
||||||
setupURL := baseURL + "/setup"
|
setupURL := baseURL + "/setup"
|
||||||
go PingUntil(ctx, baseURL, func() {
|
go PingUntil(ctx, time.Second, baseURL, func() {
|
||||||
if err := openURL(setupURL); err != nil {
|
if err := openURL(setupURL); err != nil {
|
||||||
logrus.WithError(err).Errorf("can not call open command to open the web page")
|
logrus.WithError(err).Errorf("can not call open command to open the web page")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user