Merge branch 'main' of github.com:harmony-one/harmony into main

pull/3355/head
Rongjian Lan 4 years ago
commit aaf6250301
  1. 10
      cmd/harmony/main.go
  2. 3
      common/ntp/ntp.go

@ -278,9 +278,13 @@ func setupNodeAndRun(hc harmonyConfig) {
// Check NTP configuration
accurate, err := ntp.CheckLocalTimeAccurate(nodeConfig.NtpServer)
if !accurate {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
fmt.Fprintf(os.Stderr, "Error: local timeclock is not accurate. Please config NTP properly.\n")
os.Exit(1)
if os.IsTimeout(err) {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
fmt.Fprintf(os.Stderr, "NTP query timed out. Continuing.\n")
} else {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
fmt.Fprintf(os.Stderr, "Error: local timeclock is not accurate. Please config NTP properly.\n")
}
}
if err != nil {
utils.Logger().Warn().Err(err).Msg("Check Local Time Accuracy Error")

@ -20,7 +20,8 @@ var (
// CheckLocalTimeAccurate returns whether the local clock accurate or not
func CheckLocalTimeAccurate(ntpServer string) (bool, error) {
response, err := beevik_ntp.Query(ntpServer)
options := beevik_ntp.QueryOptions{Timeout: 10 * time.Second}
response, err := beevik_ntp.QueryWithOptions(ntpServer, options)
// failed to query ntp time
if err != nil {
return false, err

Loading…
Cancel
Save