1 Star 2 Fork 0

spwx820/cloud_db_ops

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
Your Name 提交于 2020-10-14 23:17 . small fix
package main
import (
"cloud_db_ops/common/utils"
_ "cloud_db_ops/web/boot"
_ "cloud_db_ops/web/router"
"os"
"os/signal"
"syscall"
"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) {
utils.ExportConfigEnvFile()
},
}
// Execute Execute
func Execute() {
rootCmd.AddCommand(exportCmd)
if err := rootCmd.Execute(); err != nil {
glog.Info(err)
os.Exit(1)
}
}
func startServer() {
utils.ExportConfigEnvFile()
stop := make(chan os.Signal, 1)
signal.Notify(stop, syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP)
go runServer()
// logging.Info(context.Background(), "server starting...")
select {
case <-stop:
// utils.Clean()
return
}
}
func runServer() {
g.Server().Run()
}
// @title 测试服务
// @version 1.0
// @description This is a sample server
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @BasePath /
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
func main() {
Execute()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/spwx/cloud_db_ops.git
git@gitee.com:spwx/cloud_db_ops.git
spwx
cloud_db_ops
cloud_db_ops
master

搜索帮助