implement graceful shutdown to webhook mode
ensures all pending tasks are finished before quit.
This commit is contained in:
parent
a10a04e1ce
commit
6bae5d11c2
3 changed files with 172 additions and 133 deletions
|
|
@ -70,7 +70,7 @@ is up to you, eg. Nginx, Apache, or even a simple Go server.
|
|||
GitPass: token,
|
||||
}
|
||||
|
||||
s, err := lib.UseWebhook(bind, cfg)
|
||||
s, r, err := lib.UseWebhook(bind, cfg)
|
||||
if err != nil {
|
||||
fmt.Println("cannot create server: ", err)
|
||||
return
|
||||
|
|
@ -85,7 +85,11 @@ is up to you, eg. Nginx, Apache, or even a simple Go server.
|
|||
defer stop()
|
||||
|
||||
fmt.Println("starting server")
|
||||
httptask.Server(s, task.Timeout(10*time.Second)).Run(ctx)
|
||||
task.Wait(
|
||||
httptask.Server(s, task.Timeout(10*time.Second)),
|
||||
r.Run,
|
||||
).Run(ctx)
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue