diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-04-27 13:36:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-27 13:36:40 +0100 |
commit | d7cc187ec00410b949ffae1625835f8ac9f36c29 (patch) | |
tree | 9b4c885474541d94fc91fc92e84ea7e025b2d5e3 /setup/base | |
parent | 54ff4cf690918886c7e7a59a65ccff970c3aa1fc (diff) |
Prevent JetStream from handling OS signals, allow running as a Windows service (#2385)
* Prevent JetStream from handling OS signals, allow running as a Windows service (fixes #2374)
* Remove double import
Diffstat (limited to 'setup/base')
-rw-r--r-- | setup/base/base.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/setup/base/base.go b/setup/base/base.go index 43d613b0..28115344 100644 --- a/setup/base/base.go +++ b/setup/base/base.go @@ -42,6 +42,7 @@ import ( userdb "github.com/matrix-org/dendrite/userapi/storage" "github.com/gorilla/mux" + "github.com/kardianos/minwinsvc" appserviceAPI "github.com/matrix-org/dendrite/appservice/api" asinthttp "github.com/matrix-org/dendrite/appservice/inthttp" @@ -462,7 +463,8 @@ func (b *BaseDendrite) SetupAndServeHTTP( }() } - <-b.ProcessContext.WaitForShutdown() + minwinsvc.SetOnExit(b.ProcessContext.ShutdownDendrite) + b.WaitForShutdown() ctx, cancel := context.WithCancel(context.Background()) cancel() @@ -475,7 +477,10 @@ func (b *BaseDendrite) SetupAndServeHTTP( func (b *BaseDendrite) WaitForShutdown() { sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) - <-sigs + select { + case <-sigs: + case <-b.ProcessContext.WaitForShutdown(): + } signal.Reset(syscall.SIGINT, syscall.SIGTERM) logrus.Warnf("Shutdown signal received") |