1 Star 0 Fork 888

JohnAbruzzi/goproxy

forked from 狂奔的蜗牛./goproxy 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
arraykeys@gmail.com 提交于 2018-10-19 16:35 . a
package main
import (
"fmt"
"log"
"os"
"os/signal"
"runtime/debug"
"syscall"
"github.com/snail007/goproxy/services"
)
var APP_VERSION = "No Version Provided"
func main() {
err := initConfig()
if err != nil {
log.Fatalf("err : %s", err)
}
if service != nil && service.S != nil {
Clean(&service.S)
} else {
Clean(nil)
}
}
func Clean(s *services.Service) {
signalChan := make(chan os.Signal, 1)
cleanupDone := make(chan bool)
signal.Notify(signalChan,
os.Interrupt,
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT)
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed, err: %s\nstack:\n%s", e, string(debug.Stack()))
}
}()
for _ = range signalChan {
log.Println("Received an interrupt, stopping services...")
if s != nil && *s != nil {
(*s).Clean()
}
if cmd != nil {
log.Printf("clean process %d", cmd.Process.Pid)
cmd.Process.Kill()
}
if *isDebug {
saveProfiling()
}
cleanupDone <- true
}
}()
<-cleanupDone
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/JohnAbruzzi/proxy.git
git@gitee.com:JohnAbruzzi/proxy.git
JohnAbruzzi
proxy
goproxy
master

搜索帮助