vspd: Remove shutdownRequestChannel.

The removal of the requestShutdown function in a previous commit means
that the shutdownRequestChannel is no longer needed, so this commit
removes it.
This commit is contained in:
jholdstock 2023-09-18 13:51:06 +01:00 committed by Jamie Holdstock
parent d10e7daf74
commit 546a87fd5b
2 changed files with 5 additions and 17 deletions

View File

@ -107,7 +107,7 @@ func run() int {
var shutdownWg sync.WaitGroup
// Create a context that is canceled when a shutdown request is received
// through an interrupt signal.
// through an interrupt signal such as SIGINT (Ctrl+C).
ctx := shutdownListener(log)
// Start the webapi server.

View File

@ -13,10 +13,6 @@ import (
"github.com/decred/slog"
)
// shutdownRequestChannel is used to initiate shutdown from one of the
// subsystems using the same code paths as when an interrupt signal is received.
var shutdownRequestChannel = make(chan struct{})
// interruptSignals defines the signals that are handled to do a clean shutdown.
// Conditional compilation is used to also include SIGTERM and SIGHUP on Unix.
var interruptSignals = []os.Signal{os.Interrupt}
@ -31,24 +27,16 @@ func shutdownListener(log slog.Logger) context.Context {
signal.Notify(interruptChannel, interruptSignals...)
// Listen for the initial shutdown signal.
select {
case sig := <-interruptChannel:
sig := <-interruptChannel
log.Infof("Received signal (%s). Shutting down...", sig)
case <-shutdownRequestChannel:
log.Info("Shutdown requested. Shutting down...")
}
cancel()
// Listen for any more shutdown request and display a message so the
// user knows the shutdown is in progress and the process is not hung.
for {
select {
case sig := <-interruptChannel:
sig := <-interruptChannel
log.Infof("Received signal (%s). Already shutting down...", sig)
case <-shutdownRequestChannel:
log.Info("Shutdown requested. Already shutting down...")
}
}
}()
return ctx