-
-
Notifications
You must be signed in to change notification settings - Fork 851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(worker): support graceful shutdown #459
Conversation
notifications workers and queue have are sent to APNs/FCM before a push notification service is shutdown. fixed: #441 Signed-off-by: Bo-Yi Wu <[email protected]>
ctx, cancel := context.WithCancel(ctx) | ||
go func() { | ||
c := make(chan os.Signal) | ||
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SA1017: the channel used with signal.Notify should be buffered (from staticcheck
)
Signed-off-by: Bo-Yi Wu <[email protected]>
Signed-off-by: Bo-Yi Wu <[email protected]>
send buffered channel to signal.Notify to avoid blocking golang/lint#175 Signed-off-by: Bo-Yi Wu <[email protected]>
main.go
Outdated
ctx, cancel := context.WithCancel(ctx) | ||
go func() { | ||
c := make(chan os.Signal, 1) | ||
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SA1016: os.Kill cannot be trapped (did you mean syscall.SIGTERM?) (from staticcheck
)
Codecov Report
@@ Coverage Diff @@
## master #459 +/- ##
==========================================
- Coverage 83.05% 82.99% -0.06%
==========================================
Files 20 20
Lines 1393 1394 +1
==========================================
Hits 1157 1157
- Misses 188 189 +1
Partials 48 48
Continue to review full report at Codecov.
|
notifications workers and queue have are sent to APNs/FCM before a push notification service is shutdown.
fixed: #441
how to test
# build docker make build_linux_amd64 docker_image
create a new console:
create another console:
You will see the log in the first console:
Signed-off-by: Bo-Yi Wu [email protected]