Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "vblog", Short: "微博客系统后台API Server", Long: "微博客系统后台API Server", RunE: func(cmd *cobra.Command, args []string) error { if vers { fmt.Println(version.FullVersion()) return nil } return cmd.Help() }, }
RootCmd represents the base command when called without any subcommands
View Source
var StartCmd = &cobra.Command{ Use: "start", Short: "启动 API Server", Long: "启动 API Server", RunE: func(cmd *cobra.Command, args []string) error { if err := loadConfig(); err != nil { return err } loadGlobal() ch := make(chan os.Signal, 1) signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP, syscall.SIGQUIT) http := protocol.NewHTTP() wg := &sync.WaitGroup{} wg.Add(1) go func() { defer wg.Done() for v := range ch { zap.L().Infof("receive signal: %s, stop service", v) switch v { case syscall.SIGHUP: if err := loadConfig(); err != nil { zap.L().Errorf("reload config error, %s", err) } default: ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() http.Stop(ctx) } return } }() if err := http.Start(); err != nil { return err } wg.Wait() return nil }, }
StartCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.