startup

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Startup

func Startup(components *component.Components, name string)

func WithAppEnv

func WithAppEnv(c *cli.Context, configType, configName string)
func serve(c *cli.Context) error {
	//设置读取的文件类型
	viper.SetConfigType("toml")
	viper.AddConfigPath(c.String("c"))
	viper.SetConfigName("config.toml")
	err := viper.ReadInConfig()
	if err != nil {
		log.Fatalf("ReadInConfig", err.Error())
	}
	//性能检测
	if c.Bool("debug.cpuprofile") {
		filename := fmt.Sprintf("cpuprofile-%d.pprof", time.Now().Unix())
		f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, os.ModePerm)
		if err != nil {
			panic(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}
	components := comps.Comps(NewComponent())
	//startup.Startup(components)
	wg := sync.WaitGroup{}
	wg.Add(1)
	go func() { defer wg.Done(); startup.Startup(components) }()
	wg.Wait()
	return nil
}

AppEnv 为 urfave/cli 方式启动的APP 设置 环境变量 urfave/cli is a declarative, simple, fast, and fun package for building command line tools in Go featuring

Types

This section is empty.

Jump to

Keyboard shortcuts

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