-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[api] API delay before readiness #4516
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import ( | |
"net/http/pprof" | ||
"runtime" | ||
"sync" | ||
"time" | ||
|
||
"github.com/pkg/errors" | ||
"go.uber.org/zap" | ||
|
@@ -231,9 +232,18 @@ func StartServer(ctx context.Context, svr *Server, probeSvr *probe.Server, cfg c | |
log.L().Panic("Failed to stop server.", zap.Error(err)) | ||
} | ||
}() | ||
if cfg.API.ReadyDuration > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. which apis or functions will be impacted? any of them could be started? e.g., heartbeat There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The waiting occurs after all lifecycle items (e.g., API, P2P) have already started, except for the heartBeat logging and admin API(for debug). From an external perspective:
|
||
// wait for a while to make sure the server is ready | ||
// The original intention was to ensure that all transactions that were not received during the restart were included in block, thereby avoiding inconsistencies in the state of the API node. | ||
log.L().Info("Waiting for server to be ready.", zap.Duration("duration", cfg.API.ReadyDuration)) | ||
readyTimer := time.NewTimer(cfg.API.ReadyDuration) | ||
<-readyTimer.C | ||
readyTimer.Stop() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can simplify to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
} | ||
if err := probeSvr.TurnOn(); err != nil { | ||
log.L().Panic("Failed to turn on probe server.", zap.Error(err)) | ||
} | ||
log.L().Info("Server is ready.") | ||
|
||
if cfg.System.HeartbeatInterval > 0 { | ||
task := routine.NewRecurringTask(NewHeartbeatHandler(svr, cfg.Network).Log, cfg.System.HeartbeatInterval) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this value set? I also don't see a default value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0 is default value, which means no delay