cmd

package
v0.0.0-...-14ee9cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "demo-api",
	Short: "demo-api 后端API",
	Long:  "demo-api 后端API",
	RunE: func(cmd *cobra.Command, args []string) error {
		if vers {
			fmt.Println(version.FullVersion())
			return nil
		}
		return errors.New("no flag find")
	},
}

RootCmd represents the base command when called without any subcommands

View Source
var StartCmd = &cobra.Command{
	Use:   "start",
	Short: "启动 demo 后端API",
	Long:  "启动 demo 后端API",
	RunE: func(cmd *cobra.Command, args []string) error {

		err := conf.LoadConfigFromToml(confFile)
		if err != nil {
			panic(err)
		}

		err = loadGlobalLogger()
		if err != nil {
			return err
		}

		apps.InitImpl()

		api := http.NewHostHTTPHander()
		api.Config()

		svc := NewManager()
		ch := make(chan os.Signal, 1)
		defer close(ch)
		signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGHUP)
		go svc.WaitStop(ch)
		return svc.Start()
	},
}

StartCmd 程序的启动时 组装都在这里进行 1. StartCmd represents the base command when called without any subcommands

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *Manager

func (*Manager) Start

func (m *Manager) Start() error

func (*Manager) WaitStop

func (m *Manager) WaitStop(ch <-chan os.Signal) error

处理来自外部的中断信号,比如Terminal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL