mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
@ -447,6 +447,9 @@ func (s *Server) Run() {
|
||||
func Wait() {
|
||||
var ctx = context.TODO()
|
||||
|
||||
// Signal handler in asynchronous way.
|
||||
go handleProcessSignal()
|
||||
|
||||
<-allShutdownChan
|
||||
// Remove plugins.
|
||||
serverMapping.Iterator(func(k string, v interface{}) bool {
|
||||
|
||||
@ -168,3 +168,16 @@ func Test_BuildParams(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func Test_ServerSignal(t *testing.T) {
|
||||
s := g.Server(guid.S())
|
||||
s.BindHandler("/", func(r *ghttp.Request) {
|
||||
r.Response.Write("hello world")
|
||||
})
|
||||
gtest.Assert(s.Start(), nil)
|
||||
g.Wait()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertEQ(s.Shutdown(), nil)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user