add backend tpl
This commit is contained in:
42
backend/main.go
Normal file → Executable file
42
backend/main.go
Normal file → Executable file
@@ -1,43 +1,29 @@
|
||||
/*
|
||||
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
||||
*/
|
||||
//go:generate atomctl gen routes
|
||||
//go:generate swag fmt
|
||||
//go:generate swag init -ot json
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.ipao.vip/rogeecn/mp-qvyun/cmd"
|
||||
"git.ipao.vip/rogeecn/mp-qvyun/conf"
|
||||
serviceHttp "backend/services"
|
||||
|
||||
"git.ipao.vip/rogeecn/atom"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "qvyun",
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := conf.Load(cmd.Flag("config").Value.String()); err != nil {
|
||||
return err
|
||||
}
|
||||
providers := serviceHttp.Default()
|
||||
|
||||
if cmd.Flag("debug").Value.String() == "true" {
|
||||
conf.C.Debug = true
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
opts := []atom.Option{
|
||||
atom.Name("backend"),
|
||||
atom.RunE(func(cmd *cobra.Command, args []string) error {
|
||||
return serviceHttp.Serve()
|
||||
}),
|
||||
}
|
||||
|
||||
rootCmd.PersistentFlags().StringP("config", "C", "", "config file")
|
||||
rootCmd.PersistentFlags().BoolP("debug", "D", false, "debug mode")
|
||||
|
||||
cmd.CommandServe(rootCmd)
|
||||
cmd.CommandMigrate(rootCmd)
|
||||
|
||||
err := rootCmd.Execute()
|
||||
if err != nil {
|
||||
if err := atom.Serve(providers, opts...); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user