mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-31 01:10:20 -06:00
Merge pull request #10363 from 2403905/issue-10360
Fix panic when stopping the nats
This commit is contained in:
6
changelog/unreleased/fix-panic-nats.md
Normal file
6
changelog/unreleased/fix-panic-nats.md
Normal file
@@ -0,0 +1,6 @@
|
||||
Bugfix: Fix panic when stopping the nats
|
||||
|
||||
The nats server itself runs signal handling that the Shutdown() call in the ocis code is redundant and led to a panic.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/10363
|
||||
https://github.com/owncloud/ocis/issues/10360
|
||||
@@ -76,7 +76,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
gr.Add(func() error {
|
||||
err := make(chan error)
|
||||
err := make(chan error, 1)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
|
||||
@@ -90,7 +90,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
gr.Add(func() error {
|
||||
err := make(chan error)
|
||||
err := make(chan error, 1)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
|
||||
@@ -14,6 +14,7 @@ type NATSServer struct {
|
||||
server *nserver.Server
|
||||
}
|
||||
|
||||
// NatsOption configures the new NATSServer instance
|
||||
func NewNATSServer(ctx context.Context, logger nserver.Logger, opts ...NatsOption) (*NATSServer, error) {
|
||||
natsOpts := &nserver.Options{}
|
||||
|
||||
@@ -23,6 +24,8 @@ func NewNATSServer(ctx context.Context, logger nserver.Logger, opts ...NatsOptio
|
||||
|
||||
// enable JetStream
|
||||
natsOpts.JetStream = true
|
||||
// The NATS server itself runs the signal handling. We set `natsOpts.NoSigs = true` because we want to handle signals ourselves
|
||||
natsOpts.NoSigs = true
|
||||
|
||||
server, err := nserver.NewServer(natsOpts)
|
||||
if err != nil {
|
||||
@@ -44,6 +47,8 @@ func (n *NATSServer) ListenAndServe() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Shutdown stops the NATSServer gracefully
|
||||
func (n *NATSServer) Shutdown() {
|
||||
n.server.Shutdown()
|
||||
n.server.WaitForShutdown()
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr.Add(func() error {
|
||||
err := make(chan error)
|
||||
err := make(chan error, 1)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user