You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/20 08:30:16 UTC

[GitHub] [dubbo-go] Mulavar opened a new pull request #1470: [WIP]feat(*): add graceful shutdown

Mulavar opened a new pull request #1470:
URL: https://github.com/apache/dubbo-go/pull/1470


   <!--  Thanks for sending a pull request!
   Read https://github.com/apache/dubbo-go/blob/master/CONTRIBUTING.md before commit pull request.
   -->
   
   **What this PR does**:
   
   **Which issue(s) this PR fixes**:
   <!--
   *Automatically closes linked issue when PR is merged.
   Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
   _If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
   -->
   Fixes #
   
   **Special notes for your reviewer**:
   
   **Does this PR introduce a user-facing change?**:
   <!--
   If no, just write "NONE" in the release-note block below.
   If yes, a release note is required:
   Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
   -->
   ```release-note
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] Mulavar commented on a change in pull request #1470: feat(*): add graceful shutdown

Posted by GitBox <gi...@apache.org>.
Mulavar commented on a change in pull request #1470:
URL: https://github.com/apache/dubbo-go/pull/1470#discussion_r715331387



##########
File path: config/graceful_shutdown.go
##########
@@ -51,61 +54,49 @@ import (
 const defaultShutDownTime = time.Second * 60
 
 // nolint
-//func GracefulShutdownInit() {
-//	signals := make(chan os.Signal, 1)
-//
-//	signal.Notify(signals, ShutdownSignals...)
-//
-//	// retrieve ShutdownConfig for gracefulShutdownFilter
-//	if filter, ok := extension.GetFilter(constant.GracefulShutdownConsumerFilterKey).(config.Setter); ok && config.GetConsumerConfig().ShutdownConfig != nil {
-//		filter.Set(config.GracefulShutdownFilterShutdownConfig, config.GetConsumerConfig().ShutdownConfig)
-//	}
-//	if filter, ok := extension.GetFilter(constant.GracefulShutdownProviderFilterKey).(config.Setter); ok && config.GetProviderConfig().ShutdownConfig != nil {
-//		filter.Set(config.GracefulShutdownFilterShutdownConfig, config.GetProviderConfig().ShutdownConfig)
-//	}
-//
-//	go func() {
-//		select {
-//		case sig := <-signals:
-//			logger.Infof("get signal %s, applicationConfig will shutdown.", sig)
-//			// gracefulShutdownOnce.Do(func() {
-//			time.AfterFunc(totalTimeout(), func() {
-//				logger.Warn("Shutdown gracefully timeout, applicationConfig will shutdown immediately. ")
-//				os.Exit(0)
-//			})
-//			BeforeShutdown()
-//			// those signals' original behavior is exit with dump ths stack, so we try to keep the behavior
-//			for _, dumpSignal := range DumpHeapShutdownSignals {
-//				if sig == dumpSignal {
-//					debug.WriteHeapDump(os.Stdout.Fd())
-//				}
-//			}
-//			os.Exit(0)
-//		}
-//	}()
-//}
+func GracefulShutdownInit() {
+	signals := make(chan os.Signal, 1)
+
+	signal.Notify(signals, ShutdownSignals...)
+
+	// retrieve ShutdownConfig for gracefulShutdownFilter
+	if filter, ok := extension.GetFilter(constant.GracefulShutdownConsumerFilterKey).(Setter); ok && rootConfig.Shutdown != nil {
+		filter.Set(constant.GracefulShutdownFilterShutdownConfig, rootConfig.Shutdown)
+	}
+
+	go func() {
+		select {
+		case sig := <-signals:
+			logger.Infof("get signal %s, applicationConfig will shutdown.", sig)
+			// gracefulShutdownOnce.Do(func() {
+			time.AfterFunc(totalTimeout(), func() {
+				logger.Warn("Shutdown gracefully timeout, applicationConfig will shutdown immediately. ")
+				os.Exit(0)
+			})
+			BeforeShutdown()
+			// those signals' original behavior is exit with dump ths stack, so we try to keep the behavior
+			for _, dumpSignal := range DumpHeapShutdownSignals {
+				if sig == dumpSignal {
+					debug.WriteHeapDump(os.Stdout.Fd())
+				}
+			}
+			os.Exit(0)
+		}
+	}()
+}
 
 // BeforeShutdown provides processing flow before shutdown
 func BeforeShutdown() {
 	destroyAllRegistries()
 	// waiting for a short time so that the clients have enough time to get the notification that server shutdowns
 	// The value of configuration depends on how long the clients will get notification.
-	//waitAndAcceptNewRequests()
-
-	// reject the new request, but keeping waiting for accepting requests
-	//waitForReceivingRequests()
-
-	// we fetch the protocols from Consumer.References. Consumer.ProtocolConfig doesn't contains all protocol, like jsonrpc
-	//consumerProtocols := getConsumerProtocols()
-
-	// If this applicationConfig is not the provider, it will do nothing
-	//destroyProviderProtocols(consumerProtocols)
+	waitAndAcceptNewRequests()
 
-	// reject sending the new request, and waiting for response of sending requests
-	//waitForSendingRequests()
+	// reject sending/receiving the new request, but keeping waiting for accepting requests
+	waitForSendingAndReceivingRequests()
 
-	// If this applicationConfig is not the consumer, it will do nothing
-	//destroyConsumerProtocols(consumerProtocols)
+	// destroy all protocols
+	destroyProtocols()
 

Review comment:
       好的,我找机会看下现在metadata的实现,另外起一个pr增加这部分优雅关闭。




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #1470: feat(*): add graceful shutdown

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1470:
URL: https://github.com/apache/dubbo-go/pull/1470#issuecomment-922737619


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1470](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bb9d12d) into [config-enhance](https://codecov.io/gh/apache/dubbo-go/commit/8c0b66441b347636f2a76625e3a9b45fd04b85f0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8c0b664) will **decrease** coverage by `0.22%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/1470/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@                Coverage Diff                 @@
   ##           config-enhance    #1470      +/-   ##
   ==================================================
   - Coverage           44.13%   43.91%   -0.23%     
   ==================================================
     Files                 274      274              
     Lines               15080    15132      +52     
   ==================================================
   - Hits                 6656     6645      -11     
   - Misses               7653     7723      +70     
   + Partials              771      764       -7     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [config/graceful\_shutdown.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29uZmlnL2dyYWNlZnVsX3NodXRkb3duLmdv) | `0.00% <0.00%> (ø)` | |
   | [filter/gshutdown/filter.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmlsdGVyL2dzaHV0ZG93bi9maWx0ZXIuZ28=) | `60.00% <0.00%> (ø)` | |
   | [cluster/cluster\_impl/base\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYmFzZV9jbHVzdGVyX2ludm9rZXIuZ28=) | `50.00% <0.00%> (-12.77%)` | :arrow_down: |
   | [remoting/etcdv3/listener.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cmVtb3RpbmcvZXRjZHYzL2xpc3RlbmVyLmdv) | `46.90% <0.00%> (-5.31%)` | :arrow_down: |
   | [metrics/prometheus/reporter.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bWV0cmljcy9wcm9tZXRoZXVzL3JlcG9ydGVyLmdv) | `40.67% <0.00%> (-1.70%)` | :arrow_down: |
   | [config/config\_center\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29uZmlnL2NvbmZpZ19jZW50ZXJfY29uZmlnLmdv) | `36.73% <0.00%> (-0.53%)` | :arrow_down: |
   | [remoting/kubernetes/listener.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cmVtb3Rpbmcva3ViZXJuZXRlcy9saXN0ZW5lci5nbw==) | `52.83% <0.00%> (ø)` | |
   | [remoting/kubernetes/registry\_controller.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cmVtb3Rpbmcva3ViZXJuZXRlcy9yZWdpc3RyeV9jb250cm9sbGVyLmdv) | `51.62% <0.00%> (+0.97%)` | :arrow_up: |
   | [remoting/kubernetes/client.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cmVtb3Rpbmcva3ViZXJuZXRlcy9jbGllbnQuZ28=) | `71.91% <0.00%> (+2.24%)` | :arrow_up: |
   | [remoting/kubernetes/watch.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cmVtb3Rpbmcva3ViZXJuZXRlcy93YXRjaC5nbw==) | `80.55% <0.00%> (+3.70%)` | :arrow_up: |
   | ... and [1 more](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [8c0b664...bb9d12d](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #1470: [WIP]feat(*): add graceful shutdown

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1470:
URL: https://github.com/apache/dubbo-go/pull/1470#issuecomment-922737619


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1470](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5dc02a1) into [config-enhance](https://codecov.io/gh/apache/dubbo-go/commit/8c0b66441b347636f2a76625e3a9b45fd04b85f0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8c0b664) will **decrease** coverage by `0.20%`.
   > The diff coverage is `0.00%`.
   
   > :exclamation: Current head 5dc02a1 differs from pull request most recent head bb9d12d. Consider uploading reports for the commit bb9d12d to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/1470/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@                Coverage Diff                 @@
   ##           config-enhance    #1470      +/-   ##
   ==================================================
   - Coverage           44.13%   43.93%   -0.21%     
   ==================================================
     Files                 274      274              
     Lines               15080    15133      +53     
   ==================================================
   - Hits                 6656     6649       -7     
   - Misses               7653     7712      +59     
   - Partials              771      772       +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [config/graceful\_shutdown.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29uZmlnL2dyYWNlZnVsX3NodXRkb3duLmdv) | `0.00% <0.00%> (ø)` | |
   | [filter/gshutdown/filter.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmlsdGVyL2dzaHV0ZG93bi9maWx0ZXIuZ28=) | `60.00% <0.00%> (ø)` | |
   | [remoting/etcdv3/listener.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cmVtb3RpbmcvZXRjZHYzL2xpc3RlbmVyLmdv) | `46.90% <0.00%> (-5.31%)` | :arrow_down: |
   | [cluster/cluster\_impl/failback\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvZmFpbGJhY2tfY2x1c3Rlcl9pbnZva2VyLmdv) | `75.82% <0.00%> (-2.20%)` | :arrow_down: |
   | [config/config\_center\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29uZmlnL2NvbmZpZ19jZW50ZXJfY29uZmlnLmdv) | `36.73% <0.00%> (-0.53%)` | :arrow_down: |
   | [filter/metrics/filter.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmlsdGVyL21ldHJpY3MvZmlsdGVyLmdv) | `100.00% <0.00%> (+15.00%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [8c0b664...bb9d12d](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] LaurenceLiZhixin commented on a change in pull request #1470: feat(*): add graceful shutdown

Posted by GitBox <gi...@apache.org>.
LaurenceLiZhixin commented on a change in pull request #1470:
URL: https://github.com/apache/dubbo-go/pull/1470#discussion_r713527026



##########
File path: config/graceful_shutdown.go
##########
@@ -51,61 +54,49 @@ import (
 const defaultShutDownTime = time.Second * 60
 
 // nolint
-//func GracefulShutdownInit() {
-//	signals := make(chan os.Signal, 1)
-//
-//	signal.Notify(signals, ShutdownSignals...)
-//
-//	// retrieve ShutdownConfig for gracefulShutdownFilter
-//	if filter, ok := extension.GetFilter(constant.GracefulShutdownConsumerFilterKey).(config.Setter); ok && config.GetConsumerConfig().ShutdownConfig != nil {
-//		filter.Set(config.GracefulShutdownFilterShutdownConfig, config.GetConsumerConfig().ShutdownConfig)
-//	}
-//	if filter, ok := extension.GetFilter(constant.GracefulShutdownProviderFilterKey).(config.Setter); ok && config.GetProviderConfig().ShutdownConfig != nil {
-//		filter.Set(config.GracefulShutdownFilterShutdownConfig, config.GetProviderConfig().ShutdownConfig)
-//	}
-//
-//	go func() {
-//		select {
-//		case sig := <-signals:
-//			logger.Infof("get signal %s, applicationConfig will shutdown.", sig)
-//			// gracefulShutdownOnce.Do(func() {
-//			time.AfterFunc(totalTimeout(), func() {
-//				logger.Warn("Shutdown gracefully timeout, applicationConfig will shutdown immediately. ")
-//				os.Exit(0)
-//			})
-//			BeforeShutdown()
-//			// those signals' original behavior is exit with dump ths stack, so we try to keep the behavior
-//			for _, dumpSignal := range DumpHeapShutdownSignals {
-//				if sig == dumpSignal {
-//					debug.WriteHeapDump(os.Stdout.Fd())
-//				}
-//			}
-//			os.Exit(0)
-//		}
-//	}()
-//}
+func GracefulShutdownInit() {
+	signals := make(chan os.Signal, 1)
+
+	signal.Notify(signals, ShutdownSignals...)
+
+	// retrieve ShutdownConfig for gracefulShutdownFilter
+	if filter, ok := extension.GetFilter(constant.GracefulShutdownConsumerFilterKey).(Setter); ok && rootConfig.Shutdown != nil {
+		filter.Set(constant.GracefulShutdownFilterShutdownConfig, rootConfig.Shutdown)
+	}
+
+	go func() {
+		select {
+		case sig := <-signals:
+			logger.Infof("get signal %s, applicationConfig will shutdown.", sig)
+			// gracefulShutdownOnce.Do(func() {
+			time.AfterFunc(totalTimeout(), func() {
+				logger.Warn("Shutdown gracefully timeout, applicationConfig will shutdown immediately. ")
+				os.Exit(0)
+			})
+			BeforeShutdown()
+			// those signals' original behavior is exit with dump ths stack, so we try to keep the behavior
+			for _, dumpSignal := range DumpHeapShutdownSignals {
+				if sig == dumpSignal {
+					debug.WriteHeapDump(os.Stdout.Fd())
+				}
+			}
+			os.Exit(0)
+		}
+	}()
+}
 
 // BeforeShutdown provides processing flow before shutdown
 func BeforeShutdown() {
 	destroyAllRegistries()
 	// waiting for a short time so that the clients have enough time to get the notification that server shutdowns
 	// The value of configuration depends on how long the clients will get notification.
-	//waitAndAcceptNewRequests()
-
-	// reject the new request, but keeping waiting for accepting requests
-	//waitForReceivingRequests()
-
-	// we fetch the protocols from Consumer.References. Consumer.ProtocolConfig doesn't contains all protocol, like jsonrpc
-	//consumerProtocols := getConsumerProtocols()
-
-	// If this applicationConfig is not the provider, it will do nothing
-	//destroyProviderProtocols(consumerProtocols)
+	waitAndAcceptNewRequests()
 
-	// reject sending the new request, and waiting for response of sending requests
-	//waitForSendingRequests()
+	// reject sending/receiving the new request, but keeping waiting for accepting requests
+	waitForSendingAndReceivingRequests()
 
-	// If this applicationConfig is not the consumer, it will do nothing
-	//destroyConsumerProtocols(consumerProtocols)
+	// destroy all protocols
+	destroyProtocols()
 

Review comment:
       可否在这里加上metadata report的销毁?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] codecov-commenter commented on pull request #1470: [WIP]feat(*): add graceful shutdown

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #1470:
URL: https://github.com/apache/dubbo-go/pull/1470#issuecomment-922737619


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1470](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5dc02a1) into [config-enhance](https://codecov.io/gh/apache/dubbo-go/commit/8c0b66441b347636f2a76625e3a9b45fd04b85f0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8c0b664) will **decrease** coverage by `0.20%`.
   > The diff coverage is `0.00%`.
   
   > :exclamation: Current head 5dc02a1 differs from pull request most recent head c7fe9d8. Consider uploading reports for the commit c7fe9d8 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/1470/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@                Coverage Diff                 @@
   ##           config-enhance    #1470      +/-   ##
   ==================================================
   - Coverage           44.13%   43.93%   -0.21%     
   ==================================================
     Files                 274      274              
     Lines               15080    15133      +53     
   ==================================================
   - Hits                 6656     6649       -7     
   - Misses               7653     7712      +59     
   - Partials              771      772       +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [config/graceful\_shutdown.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29uZmlnL2dyYWNlZnVsX3NodXRkb3duLmdv) | `0.00% <0.00%> (ø)` | |
   | [filter/gshutdown/filter.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmlsdGVyL2dzaHV0ZG93bi9maWx0ZXIuZ28=) | `60.00% <0.00%> (ø)` | |
   | [remoting/etcdv3/listener.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cmVtb3RpbmcvZXRjZHYzL2xpc3RlbmVyLmdv) | `46.90% <0.00%> (-5.31%)` | :arrow_down: |
   | [cluster/cluster\_impl/failback\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvZmFpbGJhY2tfY2x1c3Rlcl9pbnZva2VyLmdv) | `75.82% <0.00%> (-2.20%)` | :arrow_down: |
   | [config/config\_center\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29uZmlnL2NvbmZpZ19jZW50ZXJfY29uZmlnLmdv) | `36.73% <0.00%> (-0.53%)` | :arrow_down: |
   | [filter/metrics/filter.go](https://codecov.io/gh/apache/dubbo-go/pull/1470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmlsdGVyL21ldHJpY3MvZmlsdGVyLmdv) | `100.00% <0.00%> (+15.00%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [8c0b664...c7fe9d8](https://codecov.io/gh/apache/dubbo-go/pull/1470?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] zouyx commented on a change in pull request #1470: feat(*): add graceful shutdown

Posted by GitBox <gi...@apache.org>.
zouyx commented on a change in pull request #1470:
URL: https://github.com/apache/dubbo-go/pull/1470#discussion_r713556278



##########
File path: config/graceful_shutdown.go
##########
@@ -120,68 +111,56 @@ func destroyAllRegistries() {
 	registryProtocol.Destroy()
 }
 
-func destroyConsumerProtocols(consumerProtocols *gxset.HashSet) {
-	logger.Info("Graceful shutdown --- Destroy consumer's protocols. ")
+// destroyProtocols destroys protocols.
+// First we destroy provider's protocols, and then we destroy the consumer protocols.
+func destroyProtocols() {
+	logger.Info("Graceful shutdown --- Destroy protocols. ")
+	logger.Info("Graceful shutdown --- First destroy provider's protocols. ")

Review comment:
       What about combine this two logs?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] LaurenceLiZhixin merged pull request #1470: feat(*): add graceful shutdown

Posted by GitBox <gi...@apache.org>.
LaurenceLiZhixin merged pull request #1470:
URL: https://github.com/apache/dubbo-go/pull/1470


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org