mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-01-24 03:29:05 +08:00
06292b603b
This reverts commit 64ed43b7ca
.
31 lines
668 B
Go
31 lines
668 B
Go
// Package cmd
|
|
// @Link https://github.com/bufanyun/hotgo
|
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
|
// @Author Ms <133814250@qq.com>
|
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
|
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"github.com/gogf/gf/v2/os/gproc"
|
|
"hotgo/utility/simple"
|
|
"os"
|
|
"sync"
|
|
)
|
|
|
|
var (
|
|
serverCloseSignal = make(chan struct{}, 1)
|
|
serverWg = sync.WaitGroup{}
|
|
)
|
|
|
|
func signalHandlerForOverall(sig os.Signal) {
|
|
serverCloseSignal <- struct{}{}
|
|
}
|
|
|
|
func signalListen(ctx context.Context, handler ...gproc.SigHandler) {
|
|
simple.SafeGo(ctx, func(ctx context.Context) {
|
|
gproc.AddSigHandlerShutdown(handler...)
|
|
gproc.Listen()
|
|
})
|
|
}
|