no more shutdown
parent
73372ed907
commit
99da67007d
|
@ -382,9 +382,6 @@ func (s *Server) Open() error {
|
||||||
go s.startServerReporting()
|
go s.startServerReporting()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch the meta store for a remote shutdown
|
|
||||||
go s.monitorShutdown(s.MetaStore.MonitorShutdown())
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
|
@ -395,23 +392,6 @@ func (s *Server) Open() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) monitorShutdown(c <-chan struct{}) {
|
|
||||||
// TODO corylanou stop the server from coming back up
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-c:
|
|
||||||
err := s.Close()
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
os.Exit(0)
|
|
||||||
case <-s.closing:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close shuts down the meta and data stores and all services.
|
// Close shuts down the meta and data stores and all services.
|
||||||
func (s *Server) Close() error {
|
func (s *Server) Close() error {
|
||||||
stopProfile()
|
stopProfile()
|
||||||
|
|
|
@ -82,12 +82,11 @@ type Store struct {
|
||||||
|
|
||||||
raftState raftState
|
raftState raftState
|
||||||
|
|
||||||
ready chan struct{}
|
ready chan struct{}
|
||||||
err chan error
|
err chan error
|
||||||
closing chan struct{}
|
closing chan struct{}
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
changed chan struct{}
|
changed chan struct{}
|
||||||
shutdown chan struct{}
|
|
||||||
|
|
||||||
// clusterTracingEnabled controls whether low-level cluster communcation is logged.
|
// clusterTracingEnabled controls whether low-level cluster communcation is logged.
|
||||||
// Useful for troubleshooting
|
// Useful for troubleshooting
|
||||||
|
@ -140,11 +139,10 @@ func NewStore(c *Config) *Store {
|
||||||
peers: c.Peers,
|
peers: c.Peers,
|
||||||
data: &Data{},
|
data: &Data{},
|
||||||
|
|
||||||
ready: make(chan struct{}),
|
ready: make(chan struct{}),
|
||||||
err: make(chan error),
|
err: make(chan error),
|
||||||
closing: make(chan struct{}),
|
closing: make(chan struct{}),
|
||||||
changed: make(chan struct{}),
|
changed: make(chan struct{}),
|
||||||
shutdown: make(chan struct{}),
|
|
||||||
|
|
||||||
clusterTracingEnabled: c.ClusterTracing,
|
clusterTracingEnabled: c.ClusterTracing,
|
||||||
retentionAutoCreate: c.RetentionAutoCreate,
|
retentionAutoCreate: c.RetentionAutoCreate,
|
||||||
|
@ -576,9 +574,6 @@ func (s *Store) Ready() <-chan struct{} { return s.ready }
|
||||||
// Err returns a channel for all out-of-band errors.
|
// Err returns a channel for all out-of-band errors.
|
||||||
func (s *Store) Err() <-chan error { return s.err }
|
func (s *Store) Err() <-chan error { return s.err }
|
||||||
|
|
||||||
// MonitorShutdown returns a channel to monitor when this node has been told to shut down remotely
|
|
||||||
func (s *Store) MonitorShutdown() <-chan struct{} { return s.shutdown }
|
|
||||||
|
|
||||||
// IsLeader returns true if the store is currently the leader.
|
// IsLeader returns true if the store is currently the leader.
|
||||||
func (s *Store) IsLeader() bool {
|
func (s *Store) IsLeader() bool {
|
||||||
s.mu.RLock()
|
s.mu.RLock()
|
||||||
|
@ -1697,15 +1692,7 @@ func (fsm *storeFSM) applyRemovePeerCommand(cmd *internal.Command) interface{} {
|
||||||
// ignore the error, as it's likely just telling you it's not the leader, and that's fine
|
// ignore the error, as it's likely just telling you it's not the leader, and that's fine
|
||||||
fsm.raftState.removePeer(addr)
|
fsm.raftState.removePeer(addr)
|
||||||
}
|
}
|
||||||
go func(id uint64, addr string) {
|
|
||||||
// Give the cluster some time to responsd
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
fsm.Logger.Printf("shutting down local node '%d'", id)
|
|
||||||
close(fsm.shutdown)
|
|
||||||
}(id, addr)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue