aboutsummaryrefslogtreecommitdiff
path: root/setup
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-04-27 13:36:40 +0100
committerGitHub <noreply@github.com>2022-04-27 13:36:40 +0100
commitd7cc187ec00410b949ffae1625835f8ac9f36c29 (patch)
tree9b4c885474541d94fc91fc92e84ea7e025b2d5e3 /setup
parent54ff4cf690918886c7e7a59a65ccff970c3aa1fc (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')
-rw-r--r--setup/base/base.go9
-rw-r--r--setup/jetstream/nats.go1
2 files changed, 8 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")
diff --git a/setup/jetstream/nats.go b/setup/jetstream/nats.go
index 1c8a89e8..8d528969 100644
--- a/setup/jetstream/nats.go
+++ b/setup/jetstream/nats.go
@@ -44,6 +44,7 @@ func Prepare(process *process.ProcessContext, cfg *config.JetStream) (natsclient
StoreDir: string(cfg.StoragePath),
NoSystemAccount: true,
MaxPayload: 16 * 1024 * 1024,
+ NoSigs: true,
})
if err != nil {
panic(err)