mh_server/cmd/root.go

38 lines
803 B
Go
Raw Permalink Normal View History

2021-06-30 02:12:05 +00:00
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"mh-server/config"
"mh-server/lib/log"
"mh-server/model"
"os"
)
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "server",
Short: "A brief description of your application",
Long: `A longer description`,
}
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
fmt.Println("rootCmd init...")
config.Init()
log.Init(viper.GetString("LOG_PATH"), viper.GetString("LOG_FILE_NAME"), config.AppConfig.LogLevel)
model.InitDB()
}