diff --git a/main.go b/main.go index 212c28f50..2c1508550 100644 --- a/main.go +++ b/main.go @@ -4,9 +4,14 @@ import ( "fmt" "os" + "github.com/hashicorp/consul/lib" "github.com/mitchellh/cli" ) +func init() { + lib.SeedMathRand() +} + func main() { os.Exit(Run(os.Args[1:])) } diff --git a/nomad/server.go b/nomad/server.go index 1aad13948..8553d0c7c 100644 --- a/nomad/server.go +++ b/nomad/server.go @@ -249,11 +249,6 @@ func NewServer(config *Config) (*Server, error) { // Emit metrics go s.heartbeatStats() - // Seed the global random. - if err := seedRandom(); err != nil { - return nil, err - } - // Done return s, nil } diff --git a/nomad/util.go b/nomad/util.go index 8bc3fb7d7..7a74c9542 100644 --- a/nomad/util.go +++ b/nomad/util.go @@ -2,8 +2,6 @@ package nomad import ( "fmt" - "math" - "math/big" "math/rand" "net" "os" @@ -11,8 +9,6 @@ import ( "runtime" "strconv" - crand "crypto/rand" - "github.com/hashicorp/serf/serf" ) @@ -115,14 +111,3 @@ func maxUint64(a, b uint64) uint64 { } return b } - -// seedRandom seeds the global random variable using a cryptographically random -// seed. It returns an error if determing the random seed fails. -func seedRandom() error { - n, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64)) - if err != nil { - return err - } - rand.Seed(n.Int64()) - return nil -}