示例#1
0
文件: main.go 项目: darron/goshe
// Any cleanup tasks on shutdown could happen here.
func handleCtrlC(c chan os.Signal) {
	sig := <-c
	message := fmt.Sprintf("Received '%s' - shutting down.", sig)
	cmd.Log(message, "info")
	fmt.Printf("%s\n", message)
	os.Exit(0)
}
示例#2
0
文件: main.go 项目: darron/goshe
func main() {
	logwriter, e := syslog.New(syslog.LOG_NOTICE, programName)
	if e == nil {
		log.SetOutput(logwriter)
	}
	cmd.Log(fmt.Sprintf("%s version: %s", programName, Version), "info")

	args := os.Args[1:]
	for _, arg := range args {
		if arg == "-v" || arg == "--version" {
			fmt.Printf("Version  : %s\nRevision : %s\nDate     : %s\nGo       : %s\n", Version, GitCommit, CompileDate, GoVersion)
			os.Exit(0)
		}
	}
	// Setup nice shutdown with CTRL-C.
	c := make(chan os.Signal)
	signal.Notify(c, os.Interrupt, syscall.SIGTERM)
	go handleCtrlC(c)

	// Listen for expvar if we have GOSHE_DEBUG set.
	if os.Getenv("GOSHE_DEBUG") != "" {
		go setupExpvarHTTP()
	}

	cmd.RootCmd.Execute()
}