vspd: Exit if shutdown requested during startup.

vspd runs some tasks on startup - database consistency checks, catching
up with missed blocks, etc. If a shutdown is requested while these tasks
are running, vspd should stop immediately rather than continuing to
start the web API server and other background tasks.
This commit is contained in:
jholdstock 2023-09-07 15:44:02 +01:00 committed by Jamie Holdstock
parent b5909817e4
commit b0f79e56f5

View File

@ -126,14 +126,29 @@ func (v *vspd) run() int {
v.log.Errorf("Database integrity check failed: %v", err) v.log.Errorf("Database integrity check failed: %v", err)
} }
// Stop if shutdown requested.
if ctx.Err() != nil {
return 0
}
// Run the block connected handler now to catch up with any blocks mined // Run the block connected handler now to catch up with any blocks mined
// while vspd was shut down. // while vspd was shut down.
v.blockConnected() v.blockConnected()
// Stop if shutdown requested.
if ctx.Err() != nil {
return 0
}
// Run voting wallet consistency check now to ensure all wallets are up to // Run voting wallet consistency check now to ensure all wallets are up to
// date. // date.
v.checkWalletConsistency() v.checkWalletConsistency()
// Stop if shutdown requested.
if ctx.Err() != nil {
return 0
}
// WaitGroup for services to signal when they have shutdown cleanly. // WaitGroup for services to signal when they have shutdown cleanly.
var shutdownWg sync.WaitGroup var shutdownWg sync.WaitGroup