You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by la...@apache.org on 2021/09/10 08:19:11 UTC
[dubbo-go] branch hsf-go-dependency updated: Add graceful shutdown
callback (#1450)
This is an automated email from the ASF dual-hosted git repository.
laurence pushed a commit to branch hsf-go-dependency
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/hsf-go-dependency by this push:
new 88d0943 Add graceful shutdown callback (#1450)
88d0943 is described below
commit 88d09437360c946cad40038e046d2fb4e60f07c4
Author: Laurence <45...@users.noreply.github.com>
AuthorDate: Fri Sep 10 16:19:01 2021 +0800
Add graceful shutdown callback (#1450)
* fix: pb stub function bug
* ftr: add gracefulshutdown callback
---
config/config_loader.go | 2 +-
config/graceful_shutdown.go | 3 ++-
config/graceful_shutdown_test.go | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/config/config_loader.go b/config/config_loader.go
index 6f7d6fa..4095e53 100644
--- a/config/config_loader.go
+++ b/config/config_loader.go
@@ -365,7 +365,7 @@ func Load() {
loadProviderConfig()
// init the shutdown callback
- GracefulShutdownInit()
+ GracefulShutdownInit(func() {})
}
// GetRPCService get rpc service for consumer
diff --git a/config/graceful_shutdown.go b/config/graceful_shutdown.go
index 89ac2e3..2fda982 100644
--- a/config/graceful_shutdown.go
+++ b/config/graceful_shutdown.go
@@ -54,7 +54,7 @@ import (
const defaultShutDownTime = time.Second * 60
// nolint
-func GracefulShutdownInit() {
+func GracefulShutdownInit(callBack func()) {
signals := make(chan os.Signal, 1)
@@ -70,6 +70,7 @@ func GracefulShutdownInit() {
os.Exit(0)
})
BeforeShutdown()
+ callBack()
// those signals' original behavior is exit with dump ths stack, so we try to keep the behavior
for _, dumpSignal := range DumpHeapShutdownSignals {
if sig == dumpSignal {
diff --git a/config/graceful_shutdown_test.go b/config/graceful_shutdown_test.go
index de20357..3738e77 100644
--- a/config/graceful_shutdown_test.go
+++ b/config/graceful_shutdown_test.go
@@ -28,7 +28,7 @@ import (
)
func TestGracefulShutdownInit(t *testing.T) {
- GracefulShutdownInit()
+ GracefulShutdownInit(func() {})
}
func TestBeforeShutdown(t *testing.T) {