File tree 2 files changed +8
-1
lines changed
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,14 @@ var (
27
27
28
28
// App specifies functions to control passed HTTP servers.
29
29
type App struct {
30
- // PreServeFn is a common hook notifies client that all servers are
30
+ // PreServeFn is a common hook which notifies client that all servers are
31
31
// about to start serving.
32
32
PreServeFn func (inherited bool ) error
33
33
34
+ // PreShutdownFn is a common hook which notifies client that all servers are
35
+ // about to start shutting down.
36
+ PreShutdownFn func ()
37
+
34
38
// CompleteShutdownFn is a parent's hook, a part of shutdown process
35
39
// that allows client to do extra work after all http servers will
36
40
// be shutdown. All dependent resources can be closed here.
@@ -57,6 +61,7 @@ type App struct {
57
61
func NewApp (servers ... * http.Server ) * App {
58
62
a := & App {
59
63
PreServeFn : func (inherited bool ) error { return nil },
64
+ PreShutdownFn : func () {},
60
65
CompleteShutdownFn : func () {},
61
66
PreParentExitFn : func () {},
62
67
servers : servers ,
@@ -113,6 +118,7 @@ func (a *App) Shutdown() {
113
118
}
114
119
115
120
logger .Printf ("shutdown servers..." )
121
+ a .PreShutdownFn ()
116
122
a .served .Wait ()
117
123
118
124
var wg sync.WaitGroup
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import (
17
17
// App specifies functions to control passed HTTP servers.
18
18
type App struct {
19
19
PreServeFn func (inherited bool ) error
20
+ PreShutdownFn func ()
20
21
CompleteShutdownFn func ()
21
22
PreParentExitFn func ()
22
23
servers []* http.Server
You can’t perform that action at this time.
0 commit comments