Example #1
0
File: cuid.go Project: shaovie/go
func main() {
	parseFlag()

	if showVersion {
		println("version 1.0.0")
		os.Exit(0)
	}

	if err := loadConfig(); err != nil {
		println("config - ", err.Error())
		os.Exit(0)
	}

	if toDaemon {
		if err := daemon(); err != nil {
			println("daemon - ", err.Error())
			os.Exit(0)
		}
	}

	runtime.GOMAXPROCS(runtime.NumCPU() * 2)

	go signalHandle()

	if toProfile {
		prof.StartProf()
	}

	if err := initSvc(); err != nil {
		println("init - ", err.Error())
		os.Exit(1)
	}

	if err := outputPid(ServerConfig.PidFile); err != nil {
		ilog.Error("pid - " + err.Error())
		os.Exit(0)
	}

	ilog.Rinfo("launch ok")

	err := startServer()
	if err != nil {
		println("start - ", err.Error())
	}

	os.Exit(1)
}
Example #2
0
func main() {
	parseFlag()

	if showVersion {
		fmt.Printf("version %s\n", "1.0.0")
		os.Exit(0)
	}

	//
	outputPid()

	l, err := ilog.InitLog("log")
	if err != nil {
		log.Fatalf("listen failed! [%s]", err.Error())
	}

	go signalHandle(l)

	if toProfile {
		prof.StartProf()
	}

	if err := config.Start(sConfigPath); err != nil {
		ilog.Printf("config start failed![%s]", err.Error())
	}

	if err := data.Start(); err != nil {
		ilog.Printf("data start failed![%s]", err.Error())
	}

	if err := monitor.Start(); err != nil {
		ilog.Printf("monitor start failed![%s]", err.Error())
	}

	if err := web.Start(); err != nil {
		ilog.Printf("web start failed![%s]", err.Error())
	}

	os.Exit(0)
}