snapshot of https://github.com/ThreeDotsLabs/watermill.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
master / ci (push) Failing after 0s

This commit is contained in:
upstream-mirror
2026-09-15 21:27:46 +05:00
commit ce933d1277
538 changed files with 46504 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package plugin
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/ThreeDotsLabs/watermill/message"
)
// SignalsHandler is a plugin that kills the router after SIGINT or SIGTERM is sent to the process.
func SignalsHandler(r *message.Router) error {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
go func() {
sig := <-sigs
r.Logger().Info(fmt.Sprintf("Received %s signal, closing\n", sig), nil)
err := r.Close()
if err != nil {
r.Logger().Error("Router close failed", err, nil)
}
}()
return nil
}