12345678910111213141516171819202122232425262728293031323334 |
- package cmd
- import (
- "fmt"
- "kpt-event/config"
- "kpt-event/dep"
- "kpt-event/http"
- log "gitee.com/xuyiping_admin/pkg/logger/zaplog"
- "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()
- log.Info("kpt-event: 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)
- }
- }
|