consul: Defer serf handler until initialized. Fixes #254.

This commit is contained in:
Armon Dadgar 2014-07-22 09:36:58 -04:00
parent ac745b1008
commit ce9de56469
1 changed files with 2 additions and 4 deletions

View File

@ -187,10 +187,6 @@ func NewServer(config *Config) (*Server, error) {
return nil, fmt.Errorf("Failed to start Raft: %v", err)
}
// Start the Serf listeners to prevent a deadlock
go s.lanEventHandler()
go s.wanEventHandler()
// Initialize the lan Serf
s.serfLAN, err = s.setupSerf(config.SerfLANConfig,
s.eventChLAN, serfLANSnapshot, false)
@ -198,6 +194,7 @@ func NewServer(config *Config) (*Server, error) {
s.Shutdown()
return nil, fmt.Errorf("Failed to start lan serf: %v", err)
}
go s.lanEventHandler()
// Initialize the wan Serf
s.serfWAN, err = s.setupSerf(config.SerfWANConfig,
@ -206,6 +203,7 @@ func NewServer(config *Config) (*Server, error) {
s.Shutdown()
return nil, fmt.Errorf("Failed to start wan serf: %v", err)
}
go s.wanEventHandler()
// Start listening for RPC requests
go s.listen()