1 Star 1 Fork 871

Alex314 / goproxy

forked from 狂奔的蜗牛. / goproxy 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1023 Bytes
一键复制 编辑 原始数据 按行查看 历史
arraykeys@gmail.com 提交于 2018-09-06 12:14 . v6.0
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:%s", 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
}
Go
1
https://gitee.com/fzwise/proxy.git
git@gitee.com:fzwise/proxy.git
fzwise
proxy
goproxy
master

搜索帮助