File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,14 @@ var (
2727
2828// App specifies functions to control passed HTTP servers.
2929type 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
3131 // about to start serving.
3232 PreServeFn func (inherited bool ) error
3333
34+ // PreShutdownFn is a common hook which notifies client that all servers are
35+ // about to start shutting down.
36+ PreShutdownFn func ()
37+
3438 // CompleteShutdownFn is a parent's hook, a part of shutdown process
3539 // that allows client to do extra work after all http servers will
3640 // be shutdown. All dependent resources can be closed here.
@@ -57,6 +61,7 @@ type App struct {
5761func NewApp (servers ... * http.Server ) * App {
5862 a := & App {
5963 PreServeFn : func (inherited bool ) error { return nil },
64+ PreShutdownFn : func () {},
6065 CompleteShutdownFn : func () {},
6166 PreParentExitFn : func () {},
6267 servers : servers ,
@@ -113,6 +118,7 @@ func (a *App) Shutdown() {
113118 }
114119
115120 logger .Printf ("shutdown servers..." )
121+ a .PreShutdownFn ()
116122 a .served .Wait ()
117123
118124 var wg sync.WaitGroup
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import (
1717// App specifies functions to control passed HTTP servers.
1818type App struct {
1919 PreServeFn func (inherited bool ) error
20+ PreShutdownFn func ()
2021 CompleteShutdownFn func ()
2122 PreParentExitFn func ()
2223 servers []* http.Server
You can’t perform that action at this time.
0 commit comments