123456789101112131415161718192021222324252627282930313233 |
- package cmd
- import (
- "fmt"
- "kpt-tmr-group/config"
- "kpt-tmr-group/dep"
- "kpt-tmr-group/http"
- "kpt-tmr-group/pkg/logger/logrus"
- "github.com/spf13/cobra"
- )
- // httpCmd represents the http command
- var httpCmd = &cobra.Command{
- Use: "http",
- Short: "start http server",
- Run: func(cmd *cobra.Command, args []string) {
- bootHTTPServer(config.Options())
- },
- }
- func bootHTTPServer(cfg *config.AppConfig) {
- dependency := dep.DIHttpDependency()
- logrus.Info("kpt-tmr-group: boot HTTP server")
- server := http.NewServer(
- http.ExportLogOption(),
- http.WithDependency(dependency),
- http.SetRouteOption(),
- )
- if err := server.Run(cfg.HTTPServerAddr); err != nil {
- fmt.Printf("HTTPServer run failed, err: %s", err)
- }
- }
|