1 Star 2 Fork 0

spwx820 / gfrest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
spwx820 提交于 2021-05-20 01:01 . u
package main
import (
"gfrest/common/export"
_ "gfrest/cron"
_ "gfrest/web/boot"
_ "gfrest/web/router"
"os"
"os/signal"
"syscall"
"github.com/getsentry/sentry-go"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/glog"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "",
Short: "",
Long: `cloud db ops server`,
Run: func(cmd *cobra.Command, args []string) {
startServer()
},
}
var exportCmd = &cobra.Command{
Use: "export",
Short: "export",
Long: `export db config`,
Run: func(cmd *cobra.Command, args []string) {
export.ExportConfigEnvFile()
},
}
// Execute Execute
func Execute() {
rootCmd.AddCommand(exportCmd)
if err := rootCmd.Execute(); err != nil {
glog.Info(err)
os.Exit(1)
}
}
func startServer() {
stop := make(chan os.Signal, 1)
signal.Notify(stop, syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP)
go runServer()
// log.Info(context.Background(), "server starting...")
select {
case <-stop:
// export.Clean()
return
}
}
func runServer() {
defer sentry.Recover()
g.Server().Run()
}
// @title 测试服务
// @version 1.0
// @description This is a sample server
// @BasePath /
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
func main() {
Execute()
}
1
https://gitee.com/spwx/gfrest.git
git@gitee.com:spwx/gfrest.git
spwx
gfrest
gfrest
master

搜索帮助