Skip to content
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(cgo): Implement graceful shutdown #230

Merged
merged 1 commit into from
Jul 9, 2020
Merged

feat(cgo): Implement graceful shutdown #230

merged 1 commit into from
Jul 9, 2020

Conversation

Fangop
Copy link

@Fangop Fangop commented Jul 6, 2020

  • The code has been formatted by gofmt
  • The update of go.sum and go.mod has been synchronized by go mod tidy
  • The graceful shutdown of dcurl cgo module will destroy dcurl while receiving SIGTERM and SIGINT signal as HORNET.
  • When destroying dcurl, the logger will log the warning of destroying dcurl.

Graceful Shutdown

The graceful shutdown implementation requires 2 new go package to be imported.

  • The package syscall is for the information of system call.
  • The package os and its sub package os/signal is for notifying the signal of system
    The concept of the implementation is to start a goroutine when importing dcurl module.
    The goroutine will listen to signal of the system.
    When receiving SIGTERM and SIGINT, it'll log the warning and safely destroy dcurl.

Logger

The logger is based on the primitive log package in go.
Originally, I use the go.uber.org/zap(the logger iotaledger/hive.go/logger based on) for the logger.
Consider of the complexity of the synchronization of the loggers, I used primitive log package in go for its simplicity.

Thanks for the reviewing!

cgo/pow/pow.go Outdated Show resolved Hide resolved
@jserv jserv requested a review from marktwtn July 7, 2020 07:58
cgo/pow/pow.go Outdated Show resolved Hide resolved
Gracful shutdown is a feature that allows process safely
shutting down, closing connections, freeing memory space, and so on.
The graceful shutdown implemented in this module is based on
listening to system call.
The shutdown process here will safely destroy dcurl.
@jserv jserv merged commit 021abb6 into DLTcollab:develop Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants