goc/cmd/server.go

28 lines
831 B
Go
Raw Normal View History

2021-06-10 12:03:47 +00:00
package cmd
import (
2021-06-20 13:15:51 +00:00
"github.com/qiniu/goc/v2/pkg/config"
2021-06-17 11:53:00 +00:00
"github.com/qiniu/goc/v2/pkg/server"
2021-06-10 12:03:47 +00:00
"github.com/spf13/cobra"
)
var serverCmd = &cobra.Command{
Use: "server",
Short: "start a service registry center",
Long: "start a service registry center",
Example: "",
Run: serve,
}
func init() {
2021-06-14 07:18:29 +00:00
// serverCmd.Flags().IntVarP(&config.GocConfig.Port, "port", "", 7777, "listen port to start a coverage host center")
// serverCmd.Flags().StringVarP(&config.GocConfig.StorePath, "storepath", "", "goc.store", "the file to save all goc server information")
2021-06-21 08:47:36 +00:00
serverCmd.Flags().StringVarP(&config.GocConfig.Host, "host", "", "127.0.0.1:7777", "specify the host of the goc server")
2021-06-10 12:03:47 +00:00
rootCmd.AddCommand(serverCmd)
}
func serve(cmd *cobra.Command, args []string) {
2021-06-20 13:15:51 +00:00
server.RunGocServerUntilExit(config.GocConfig.Host)
2021-06-10 12:03:47 +00:00
}