multi: Move signal to internal package.
This commit is contained in:
parent
2faaa8b32b
commit
935dcaece2
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/decred/dcrd/wire"
|
"github.com/decred/dcrd/wire"
|
||||||
"github.com/decred/vspd/database"
|
"github.com/decred/vspd/database"
|
||||||
"github.com/decred/vspd/internal/config"
|
"github.com/decred/vspd/internal/config"
|
||||||
|
"github.com/decred/vspd/internal/signal"
|
||||||
"github.com/decred/vspd/internal/version"
|
"github.com/decred/vspd/internal/version"
|
||||||
"github.com/decred/vspd/internal/vspd"
|
"github.com/decred/vspd/internal/vspd"
|
||||||
"github.com/decred/vspd/internal/webapi"
|
"github.com/decred/vspd/internal/webapi"
|
||||||
@ -108,7 +109,7 @@ func run() int {
|
|||||||
|
|
||||||
// Create a context that is canceled when a shutdown request is received
|
// Create a context that is canceled when a shutdown request is received
|
||||||
// through an interrupt signal such as SIGINT (Ctrl+C).
|
// through an interrupt signal such as SIGINT (Ctrl+C).
|
||||||
ctx := shutdownListener(log)
|
ctx := signal.ShutdownListener(log)
|
||||||
|
|
||||||
// Start the webapi server.
|
// Start the webapi server.
|
||||||
shutdownWg.Add(1)
|
shutdownWg.Add(1)
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package main
|
package signal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -17,10 +17,10 @@ import (
|
|||||||
// shutdown. This may be modified during init depending on the platform.
|
// shutdown. This may be modified during init depending on the platform.
|
||||||
var interruptSignals = []os.Signal{os.Interrupt}
|
var interruptSignals = []os.Signal{os.Interrupt}
|
||||||
|
|
||||||
// shutdownListener listens for OS Signals such as SIGINT (Ctrl+C) and shutdown
|
// ShutdownListener listens for OS Signals such as SIGINT (Ctrl+C) and shutdown
|
||||||
// requests from requestShutdown. It returns a context that is canceled when
|
// requests from requestShutdown. It returns a context that is canceled when
|
||||||
// either signal is received.
|
// either signal is received.
|
||||||
func shutdownListener(log slog.Logger) context.Context {
|
func ShutdownListener(log slog.Logger) context.Context {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
go func() {
|
go func() {
|
||||||
interruptChannel := make(chan os.Signal, 1)
|
interruptChannel := make(chan os.Signal, 1)
|
||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
//go:build windows || aix || android || darwin || dragonfly || freebsd || hurd || illumos || ios || linux || netbsd || openbsd || solaris
|
//go:build windows || aix || android || darwin || dragonfly || freebsd || hurd || illumos || ios || linux || netbsd || openbsd || solaris
|
||||||
|
|
||||||
package main
|
package signal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"syscall"
|
"syscall"
|
||||||
Loading…
x
Reference in New Issue
Block a user