diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index ef29c4503..94f746fd7 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -132,7 +132,8 @@ func (b *BitcoindNotifier) Stop() error { return nil } - chainntnfs.Log.Info("bitcoind notifier shutting down") + chainntnfs.Log.Info("bitcoind notifier shutting down...") + defer chainntnfs.Log.Debug("bitcoind notifier shutdown complete") // Shutdown the rpc client, this gracefully disconnects from bitcoind, // and cleans up all related resources. diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 2c2619b2c..cc52c89c2 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -169,7 +169,8 @@ func (b *BtcdNotifier) Stop() error { return nil } - chainntnfs.Log.Info("btcd notifier shutting down") + chainntnfs.Log.Info("btcd notifier shutting down...") + defer chainntnfs.Log.Debug("btcd notifier shutdown complete") // Shutdown the rpc client, this gracefully disconnects from btcd, and // cleans up all related resources. diff --git a/chainntnfs/mempool.go b/chainntnfs/mempool.go index 59ce28f7b..8bb2af4c9 100644 --- a/chainntnfs/mempool.go +++ b/chainntnfs/mempool.go @@ -174,6 +174,8 @@ func (m *MempoolNotifier) ProcessRelevantSpendTx(tx *btcutil.Tx) { // TearDown stops the notifier and cleans up resources. func (m *MempoolNotifier) TearDown() { Log.Infof("Stopping mempool notifier") + defer Log.Debug("mempool notifier stopped") + close(m.quit) m.wg.Wait() } diff --git a/chainntnfs/neutrinonotify/neutrino.go b/chainntnfs/neutrinonotify/neutrino.go index 6f8f9717c..87735a167 100644 --- a/chainntnfs/neutrinonotify/neutrino.go +++ b/chainntnfs/neutrinonotify/neutrino.go @@ -136,7 +136,8 @@ func (n *NeutrinoNotifier) Stop() error { return nil } - chainntnfs.Log.Info("neutrino notifier shutting down") + chainntnfs.Log.Info("neutrino notifier shutting down...") + defer chainntnfs.Log.Debug("neutrino notifier shutdown complete") close(n.quit) n.wg.Wait() diff --git a/chanbackup/pubsub.go b/chanbackup/pubsub.go index 3e1580ddd..5323f97aa 100644 --- a/chanbackup/pubsub.go +++ b/chanbackup/pubsub.go @@ -158,7 +158,8 @@ func (s *SubSwapper) Start() error { // Stop signals the SubSwapper to being a graceful shutdown. func (s *SubSwapper) Stop() error { s.stopped.Do(func() { - log.Infof("Stopping chanbackup.SubSwapper") + log.Infof("chanbackup.SubSwapper shutting down...") + defer log.Debug("chanbackup.SubSwapper shutdown complete") close(s.quit) s.wg.Wait() diff --git a/chanfitness/chaneventstore.go b/chanfitness/chaneventstore.go index 53a699932..c3aa25efd 100644 --- a/chanfitness/chaneventstore.go +++ b/chanfitness/chaneventstore.go @@ -203,7 +203,8 @@ func (c *ChannelEventStore) Start() error { // Stop terminates all goroutines started by the event store. func (c *ChannelEventStore) Stop() { - log.Info("Stopping event store") + log.Info("ChannelEventStore shutting down...") + defer log.Debug("ChannelEventStore shutdown complete") // Stop the consume goroutine. close(c.quit) diff --git a/channelnotifier/channelnotifier.go b/channelnotifier/channelnotifier.go index 78e1a8033..2b39396df 100644 --- a/channelnotifier/channelnotifier.go +++ b/channelnotifier/channelnotifier.go @@ -104,7 +104,9 @@ func (c *ChannelNotifier) Start() error { func (c *ChannelNotifier) Stop() error { var err error c.stopped.Do(func() { - log.Info("ChannelNotifier shutting down") + log.Info("ChannelNotifier shutting down...") + defer log.Debug("ChannelNotifier shutdown complete") + err = c.ntfnServer.Stop() }) return err diff --git a/contractcourt/breacharbiter.go b/contractcourt/breacharbiter.go index 7c9cc608f..739e70f13 100644 --- a/contractcourt/breacharbiter.go +++ b/contractcourt/breacharbiter.go @@ -310,7 +310,8 @@ func (b *BreachArbiter) start() error { // the BreachArbiter have gracefully exited. func (b *BreachArbiter) Stop() error { b.stopped.Do(func() { - brarLog.Infof("Breach arbiter shutting down") + brarLog.Infof("Breach arbiter shutting down...") + defer brarLog.Debug("Breach arbiter shutdown complete") close(b.quit) b.wg.Wait() diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index ffd26e66a..acae5b678 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -919,7 +919,8 @@ func (c *ChainArbitrator) Stop() error { return nil } - log.Info("ChainArbitrator shutting down") + log.Info("ChainArbitrator shutting down...") + defer log.Debug("ChainArbitrator shutdown complete") close(c.quit) diff --git a/contractcourt/utxonursery.go b/contractcourt/utxonursery.go index 801ef28a0..57a3709e9 100644 --- a/contractcourt/utxonursery.go +++ b/contractcourt/utxonursery.go @@ -319,7 +319,8 @@ func (u *UtxoNursery) Stop() error { return nil } - utxnLog.Infof("UTXO nursery shutting down") + utxnLog.Infof("UTXO nursery shutting down...") + defer utxnLog.Debug("UTXO nursery shutdown complete") close(u.quit) u.wg.Wait() diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 305fd359e..eed3cee84 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -728,7 +728,9 @@ func (d *AuthenticatedGossiper) resendFutureMessages(height uint32) { // Stop signals any active goroutines for a graceful closure. func (d *AuthenticatedGossiper) Stop() error { d.stopped.Do(func() { - log.Info("Authenticated gossiper shutting down") + log.Info("Authenticated gossiper shutting down...") + defer log.Debug("Authenticated gossiper shutdown complete") + d.stop() }) return nil diff --git a/funding/manager.go b/funding/manager.go index bfe65407d..b26e7832b 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -754,7 +754,9 @@ func (f *Manager) start() error { // method will block until all goroutines have exited. func (f *Manager) Stop() error { f.stopped.Do(func() { - log.Info("Funding manager shutting down") + log.Info("Funding manager shutting down...") + defer log.Debug("Funding manager shutdown complete") + close(f.quit) f.wg.Wait() }) diff --git a/healthcheck/healthcheck.go b/healthcheck/healthcheck.go index 1cf6bd98c..e72d65620 100644 --- a/healthcheck/healthcheck.go +++ b/healthcheck/healthcheck.go @@ -87,7 +87,8 @@ func (m *Monitor) Stop() error { return fmt.Errorf("monitor already stopped") } - log.Info("Health monitor shutting down") + log.Info("Health monitor shutting down...") + defer log.Debug("Health monitor shutdown complete") close(m.quit) m.wg.Wait() diff --git a/htlcswitch/hop/iterator.go b/htlcswitch/hop/iterator.go index c1073b1da..14f11c567 100644 --- a/htlcswitch/hop/iterator.go +++ b/htlcswitch/hop/iterator.go @@ -139,7 +139,8 @@ func (p *OnionProcessor) Start() error { // Stop shutsdown the onion processor's sphinx router. func (p *OnionProcessor) Stop() error { - log.Info("Onion processor shutting down") + log.Info("Onion processor shutting down...") + defer log.Debug("Onion processor shutdown complete") p.router.Stop() return nil diff --git a/htlcswitch/htlcnotifier.go b/htlcswitch/htlcnotifier.go index bd7be6e7c..d6da5327d 100644 --- a/htlcswitch/htlcnotifier.go +++ b/htlcswitch/htlcnotifier.go @@ -92,7 +92,9 @@ func (h *HtlcNotifier) Start() error { func (h *HtlcNotifier) Stop() error { var err error h.stopped.Do(func() { - log.Info("HtlcNotifier shutting down") + log.Info("HtlcNotifier shutting down...") + defer log.Debug("HtlcNotifier shutdown complete") + if err = h.ntfnServer.Stop(); err != nil { log.Warnf("error stopping htlc notifier: %v", err) } diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 2d20db800..592d03a1c 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -2244,7 +2244,8 @@ func (s *Switch) Stop() error { return errors.New("htlc switch already shutdown") } - log.Info("HTLC Switch shutting down") + log.Info("HTLC Switch shutting down...") + defer log.Debug("HTLC Switch shutdown complete") close(s.quit) diff --git a/invoices/invoiceregistry.go b/invoices/invoiceregistry.go index a638f46b1..a9a5e3831 100644 --- a/invoices/invoiceregistry.go +++ b/invoices/invoiceregistry.go @@ -275,7 +275,8 @@ func (i *InvoiceRegistry) Start() error { // Stop signals the registry for a graceful shutdown. func (i *InvoiceRegistry) Stop() error { - log.Info("InvoiceRegistry shutting down") + log.Info("InvoiceRegistry shutting down...") + defer log.Debug("InvoiceRegistry shutdown complete") i.expiryWatcher.Stop() diff --git a/netann/chan_status_manager.go b/netann/chan_status_manager.go index 518fd3970..7ee543d2a 100644 --- a/netann/chan_status_manager.go +++ b/netann/chan_status_manager.go @@ -225,7 +225,9 @@ func (m *ChanStatusManager) start() error { // Stop safely shuts down the ChanStatusManager. func (m *ChanStatusManager) Stop() error { m.stopped.Do(func() { - log.Info("Channel Status Manager shutting down") + log.Info("Channel Status Manager shutting down...") + defer log.Debug("Channel Status Manager shutdown complete") + close(m.quit) m.wg.Wait() }) diff --git a/netann/host_ann.go b/netann/host_ann.go index 767c3089c..95ba277b5 100644 --- a/netann/host_ann.go +++ b/netann/host_ann.go @@ -69,7 +69,9 @@ func (h *HostAnnouncer) Start() error { // Stop signals the HostAnnouncer for a graceful stop. func (h *HostAnnouncer) Stop() error { h.stopOnce.Do(func() { - log.Info("HostAnnouncer shutting down") + log.Info("HostAnnouncer shutting down...") + defer log.Debug("HostAnnouncer shutdown complete") + close(h.quit) h.wg.Wait() }) diff --git a/peernotifier/peernotifier.go b/peernotifier/peernotifier.go index d24c2cf92..bfa5c39cc 100644 --- a/peernotifier/peernotifier.go +++ b/peernotifier/peernotifier.go @@ -52,7 +52,9 @@ func (p *PeerNotifier) Start() error { func (p *PeerNotifier) Stop() error { var err error p.stopped.Do(func() { - log.Info("PeerNotifier shutting down") + log.Info("PeerNotifier shutting down...") + defer log.Debug("PeerNotifier shutdown complete") + err = p.ntfnServer.Stop() }) return err diff --git a/routing/missioncontrol.go b/routing/missioncontrol.go index 201777af3..b3208525b 100644 --- a/routing/missioncontrol.go +++ b/routing/missioncontrol.go @@ -240,6 +240,9 @@ func (m *MissionControl) RunStoreTicker() { // StopStoreTicker stops the mission control store's ticker. func (m *MissionControl) StopStoreTicker() { + log.Debug("Stopping mission control store ticker") + defer log.Debug("Mission control store ticker stopped") + m.store.stop() } diff --git a/routing/router.go b/routing/router.go index 31deb02ea..c6a5cec21 100644 --- a/routing/router.go +++ b/routing/router.go @@ -699,7 +699,8 @@ func (r *ChannelRouter) Stop() error { return nil } - log.Info("Channel Router shutting down") + log.Info("Channel Router shutting down...") + defer log.Debug("Channel Router shutdown complete") // Our filtered chain view could've only been started if // AssumeChannelValid isn't present. diff --git a/server.go b/server.go index f82f9784e..1a8aaa9fd 100644 --- a/server.go +++ b/server.go @@ -2328,8 +2328,10 @@ func (s *server) Stop() error { } // Wait for all lingering goroutines to quit. + srvrLog.Debug("Waiting for server to shutdown...") s.wg.Wait() + srvrLog.Debug("Stopping buffer pools...") s.sigPool.Stop() s.writePool.Stop() s.readPool.Stop() @@ -3957,6 +3959,9 @@ func (s *server) peerInitializer(p *peer.Brontide) { // Start the peer! If an error occurs, we Disconnect the peer, which // will unblock the peerTerminationWatcher. if err := p.Start(); err != nil { + srvrLog.Warnf("Starting peer=%v got error: %v", + p.IdentityKey(), err) + p.Disconnect(fmt.Errorf("unable to start peer: %v", err)) return } diff --git a/sweep/sweeper.go b/sweep/sweeper.go index 4f53d2098..9de13592f 100644 --- a/sweep/sweeper.go +++ b/sweep/sweeper.go @@ -409,13 +409,12 @@ func (s *UtxoSweeper) Stop() error { return nil } - log.Info("Sweeper shutting down") + log.Info("Sweeper shutting down...") + defer log.Debug("Sweeper shutdown complete") close(s.quit) s.wg.Wait() - log.Debugf("Sweeper shut down") - return nil }