Skip to content

Commit

Permalink
add Shutdown function
Browse files Browse the repository at this point in the history
  • Loading branch information
陆丹峰 committed May 4, 2023
1 parent 5c175cf commit baebf2c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ func (boot *Boot) Bootstrap(ctx context.Context) {
func (boot *Boot) WaitForShutdownSig(ctx context.Context) {
rkentry.GlobalAppCtx.WaitForShutdownSig()

boot.Shutdown(ctx)
}

// Shutdown shutdown boot. for non-web application
// 1: Call shutdown hook function added by user.
// 2: Call interrupt function of entries in rkentry.GlobalAppCtx.
func (boot *Boot) Shutdown(ctx context.Context) {
// Call shutdown hook function
for _, f := range rkentry.GlobalAppCtx.ListShutdownHooks() {
f()
Expand Down

0 comments on commit baebf2c

Please sign in to comment.