mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-04 13:16:43 +00:00
[NOD-1239] Delete app.WaitForShutdown() (#866)
This commit is contained in:
parent
22dc3f998f
commit
ca3172dad0
17
app/app.go
17
app/app.go
@ -62,11 +62,11 @@ func (a *App) Start() {
|
||||
}
|
||||
|
||||
// Stop gracefully shuts down all the kaspad services.
|
||||
func (a *App) Stop() error {
|
||||
func (a *App) Stop() {
|
||||
// Make sure this only happens once.
|
||||
if atomic.AddInt32(&a.shutdown, 1) != 1 {
|
||||
log.Infof("Kaspad is already in the process of shutting down")
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
log.Warnf("Kaspad shutting down")
|
||||
@ -86,7 +86,12 @@ func (a *App) Stop() error {
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
err = a.addressManager.Stop()
|
||||
if err != nil {
|
||||
log.Errorf("Error stopping address manager: %s", err)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// New returns a new App instance configured to listen on addr for the
|
||||
@ -241,9 +246,3 @@ func (a *App) P2PNodeID() *id.ID {
|
||||
func (a *App) AddressManager() *addressmanager.AddressManager {
|
||||
return a.addressManager
|
||||
}
|
||||
|
||||
// WaitForShutdown blocks until the main listener and peer handlers are stopped.
|
||||
func (a *App) WaitForShutdown() {
|
||||
// TODO(libp2p)
|
||||
// a.p2pServer.WaitForShutdown()
|
||||
}
|
||||
|
@ -97,14 +97,9 @@ func setRPCClient(t *testing.T, harness *appHarness) {
|
||||
}
|
||||
|
||||
func teardownHarness(t *testing.T, harness *appHarness) {
|
||||
err := harness.app.Stop()
|
||||
if err != nil {
|
||||
t.Errorf("Error stopping App: %+v", err)
|
||||
}
|
||||
harness.app.Stop()
|
||||
|
||||
harness.app.WaitForShutdown()
|
||||
|
||||
err = harness.databaseContext.Close()
|
||||
err := harness.databaseContext.Close()
|
||||
if err != nil {
|
||||
t.Errorf("Error closing database context: %+v", err)
|
||||
}
|
||||
|
6
main.go
6
main.go
@ -132,14 +132,10 @@ func kaspadMain(startedChan chan<- struct{}) error {
|
||||
}
|
||||
defer func() {
|
||||
log.Infof("Gracefully shutting down kaspad...")
|
||||
err := app.Stop()
|
||||
if err != nil {
|
||||
log.Errorf("Error stopping kaspad: %+v", err)
|
||||
}
|
||||
|
||||
shutdownDone := make(chan struct{})
|
||||
go func() {
|
||||
app.WaitForShutdown()
|
||||
app.Stop()
|
||||
shutdownDone <- struct{}{}
|
||||
}()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user