Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{
Use: "amod",
Short: "AMO daemon management",
}
View Source
var RunCmd = &cobra.Command{ Use: "run", Short: "Execute the daemon", RunE: func(cmd *cobra.Command, args []string) error { config := cfg.DefaultConfig() amoDirPath, err := cmd.Flags().GetString("home") if err != nil { return err } config.SetRoot(amoDirPath) tmCfg.EnsureRoot(config.RootDir) configFile := filepath.Join( config.RootDir, config.ConfigDir, cfg.DefaultConfigFileName, ) vp := viper.New() vp.SetConfigFile(configFile) err = vp.ReadInConfig() if err != nil { return err } err = vp.UnmarshalExact(config) if err != nil { return err } err = config.ValidateBasic() if err != nil { return err } // set RLIMIT_NOFILE var rLimit syscall.Rlimit err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) if err != nil { return err } if config.RLimitNoFile <= rLimit.Max { rLimit.Cur = config.RLimitNoFile } err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) if err != nil { return err } logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) logger, err = tmflags.ParseLogLevel( config.LogLevel, logger, tmCfg.DefaultLogLevel(), ) app, err := initApp(config, logger) if err != nil { return err } node, err := newTM(app, config, logger) if err != nil { return err } cpuprof, _ := cmd.Flags().GetString("cpuprofile") if len(cpuprof) > 0 { f, err := os.Create(cpuprof) if err != nil { fmt.Println("unable to create cpu profile") } defer f.Close() if err := pprof.StartCPUProfile(f); err != nil { fmt.Println("unable to start cpu profile") } defer pprof.StopCPUProfile() } memprof, _ := cmd.Flags().GetString("memprofile") if len(memprof) > 0 { defer func() { mf, err := os.Create(memprof) if err != nil { fmt.Println("unable to create mem profile") } if err := pprof.WriteHeapProfile(mf); err != nil { fmt.Println("unable to write mem heap profile") } mf.Close() }() } node.Start() defer func() { node.Stop() node.ProxyApp().Stop() node.Wait() time.Sleep(200000000) }() c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) <-c return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.