1 Star 0 Fork 1

jun/gofly_framework

forked from apiok/gofly_framework 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 929 Bytes
一键复制 编辑 原始数据 按行查看 历史
youwen21 提交于 2023-07-18 16:29 . 重新初始化此仓库
package main
import (
"fmt"
"gofly/conf"
"gofly/conf/flag_vars"
"gofly/server"
"log"
"net"
"net/http"
"os"
"os/signal"
"syscall"
)
func handleSignals() {
//pid := os.Getpid()
//_ = os.WriteFile("pid", []byte(strconv.Itoa(pid)), 777)
terminateSignals := make(chan os.Signal, 1)
signal.Notify(terminateSignals, syscall.SIGINT, syscall.SIGKILL, syscall.SIGTERM) //NOTE:: syscall.SIGKILL we cannot catch kill -9 as its force kill signal.
<-terminateSignals
//_ = os.Remove("pid")
}
func main() {
fmt.Println("starting")
listener, err := net.Listen("tcp", conf.GetAddress())
if err != nil {
log.Fatal("init listener failure:", err)
}
log.Println("listen at:", conf.GetAddress())
log.Println("local open:", fmt.Sprintf("http://127.0.0.1:%v", flag_vars.GetPort()))
go func() {
err = http.Serve(listener, server.Mux)
if err != nil {
log.Fatal("http.Serve failure:", err)
}
}()
handleSignals()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mu-xin/gofly_framework.git
git@gitee.com:mu-xin/gofly_framework.git
mu-xin
gofly_framework
gofly_framework
master

搜索帮助