Пример #1
0
func main() {
	var err error
	// Parse cmd-line arguments
	flag.Parse()
	log.Info("web ver: \"%s\" start", ver.Version)
	if err = InitConfig(); err != nil {
		panic(err)
	}
	// Set max routine
	runtime.GOMAXPROCS(Conf.MaxProc)
	// init log
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	// init zookeeper
	zkConn, err := InitZK()
	if err != nil {
		if zkConn != nil {
			zkConn.Close()
		}
		panic(err)
	}
	// start pprof http
	perf.Init(Conf.PprofBind)
	// start http listen.
	StartHTTP()
	// process init
	if err = process.Init(Conf.User, Conf.Dir, Conf.PidFile); err != nil {
		panic(err)
	}
	// init signals, block wait signals
	signalCH := InitSignal()
	HandleSignal(signalCH)
	log.Info("web stop")
}
func main() {
	log.LoadConfiguration("./log4go.config")
	port, ip, account, pwd, schame := readServerPort()
	dbCon := new(dao.MysqlConnector)
	isConnect := dbCon.Connect(&ip, 3306, &account, &pwd, &schame)
	if !isConnect {
		log.Warn("mysql connect faild")
		return
	}
	server := sev.NewNexus(port, logic.TcpHandler,
		logic.ConnectedHandler, logic.DisconnectingHander,
		dbCon)
	server.Startup()
}
Пример #3
0
func main() {
	// parse cmd-line arguments
	flag.Parse()
	log.Info("comet ver: \"%s\" start", ver.Version)
	// init config
	if err := InitConfig(); err != nil {
		panic(err)
	}
	// set max routine
	runtime.GOMAXPROCS(Conf.MaxProc)
	// init log
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	// start pprof
	perf.Init(Conf.PprofBind)
	// create channel
	// if process exit, close channel
	UserChannel = NewChannelList()
	defer UserChannel.Close()
	// start stats
	StartStats()
	// start rpc
	if err := StartRPC(); err != nil {
		panic(err)
	}
	// start comet
	if err := StartComet(); err != nil {
		panic(err)
	}
	// init zookeeper
	zkConn, err := InitZK()
	if err != nil {
		if zkConn != nil {
			zkConn.Close()
		}
		panic(err)
	}
	// process init
	if err = process.Init(Conf.User, Conf.Dir, Conf.PidFile); err != nil {
		panic(err)
	}
	// init signals, block wait signals
	signalCH := InitSignal()
	HandleSignal(signalCH)
	// exit
	log.Info("comet stop")
}
Пример #4
0
func main() {
	flag.Usage = func() {
		fmt.Fprint(os.Stderr, fmt.Sprintf(usage, runtime.NumCPU()))
	}

	flag.Parse()
	if flag.NArg() < 1 {
		fmt.Fprintf(os.Stderr, " args num is %d\n", flag.NArg())
		usageAndExit("need ipaddress like this 23.45.66.78:80")
	}

	codisAddr := flag.Args()[0]
	if codisAddr == "" {
		usageAndExit("empty  ipaddress ")
	} else {
		fmt.Printf("codis client is %s\n", codisAddr)
	}

	if !checkIpAddr(codisAddr) {
		usageAndExit("invalid  ipaddress ")
	}

	runtime.GOMAXPROCS(*cpus)
	log.LoadConfiguration("./conf/log.xml")
	log.Info("con client is %d\n", *c)
	log.Info("request quantity is %d\n", *n)
	log.Info("data type is %s \n", *data_type)
	reporter.Dayreport.Init()
	reporter.Dayreport.Run()

	Runpprof()
	cmddatachecker.Filepath = *filepath
	fmt.Printf("data pth %s", cmddatachecker.Filepath)

	//c int32, req int32, ipandport string, port int16, sec int32, datatype string
	loadrunner := cmdrunner.NewCmdRunner(uint32(*c), int32(*n), codisAddr, 60, *data_type, *t, *auth_passwd)
	if *ifloop {
		loadrunner.RunLoop()
	} else {
		loadrunner.Run()
	}
}
Пример #5
0
func main() {
	runtime.GOMAXPROCS(1)
	l4g.LoadConfiguration("../conf/imgsvrd_log.xml")
	if len(os.Args) < 2 {
		l4g.Info("usage:params isn't invalid")
		os.Exit(1)
	}
	cmd := os.Args[1]
	if cmd == "-stop" {
		stop()
	}
	if cmd == "-h" {
		h()
	}
	if cmd == "-s" {
		s()
	}
	if cmd == "-reload" {
		reload()
	}
}
Пример #6
0
func main() {
	flag.Parse()
	// config
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(MyConf.MaxProc)
	// init log
	log.LoadConfiguration(MyConf.Log)
	log.Info("gosnowflake service start [datacenter: %d]", MyConf.DatacenterId)
	// process
	if err := InitProcess(); err != nil {
		panic(err)
	}
	// pprof
	InitPprof()
	// zookeeper
	if err := InitZK(); err != nil {
		panic(err)
	}
	defer CloseZK()
	// safty check
	if err := SanityCheckPeers(); err != nil {
		panic(err)
	}
	// workers
	workers, err := NewWorkers()
	if err != nil {
		panic(err)
	}
	// rpc
	if err := InitRPC(workers); err != nil {
		panic(err)
	}
	// init signals, block wait signals
	sc := InitSignal()
	HandleSignal(sc)
	log.Info("gosnowflake service stop")
}
Пример #7
0
func main() {
	flag.Parse()
	log.Info("message ver: \"%s\" start", ver.Version)
	if err := InitConfig(); err != nil {
		panic(err)
	}
	// Set max routine
	runtime.GOMAXPROCS(Conf.MaxProc)
	// init log
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	// start pprof http
	perf.Init(Conf.PprofBind)
	// Initialize redis
	if err := InitStorage(); err != nil {
		panic(err)
	}
	// init rpc service
	if err := InitRPC(); err != nil {
		panic(err)
	}
	// init zookeeper
	zk, err := InitZK()
	if err != nil {
		if zk != nil {
			zk.Close()
		}
		panic(err)
	}
	// process init
	if err = process.Init(Conf.User, Conf.Dir, Conf.PidFile); err != nil {
		panic(err)
	}
	// init signals, block wait signals
	sig := InitSignal()
	HandleSignal(sig)
	// exit
	log.Info("message stop")
}
Пример #8
0
func init() {
	logger.LoadConfiguration("./conf/log4go.xml")
}
Пример #9
0
func main() {
	// parse cmd-line arguments
	flag.Parse()
	log.Info("comet ver: \"%s\" start", ver.Version)
	// init config
	if err := InitConfig(); err != nil {
		panic(err)
	}
	// set max routine
	runtime.GOMAXPROCS(Conf.MaxProc)
	// init log
	log.Info("comet log configuration")
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	// start pprof
	log.Info("comet init perf")
	perf.Init(Conf.PprofBind)
	// create channel
	// if process exit, close channel
	UserChannel = NewChannelList()
	defer UserChannel.Close()
	// start stats
	log.Info("comet start stats")

	StartStats()
	// start rpc,应该不需要了吧?
	log.Info("comet start rpc")

	if err := InitControllerRpcClient(); err != nil {
		panic(err)
	}
	defer thriftPool.Release()

	// start comet
	log.Info("comet start ")
	if err := StartComet(); err != nil {
		panic(err)
	}

	// configuration the kafka topic and kafka consumer to consum the notify messages.
	log.Info("queue start")
	if err := StartQueue(); err != nil {
		panic(err)
	}

	// init zookeeper,用来监控instance的启动和服务down。同步instance的ip,queue,信息到配置中心。配置中心监控监控变动,同步信息到调度中心。
	zkConn, err := InitZK()
	if err != nil {
		if zkConn != nil {
			zkConn.Close()
		}
		panic(err)
	}
	// process init
	//	if err = process.Init(Conf.User, Conf.Dir, Conf.PidFile); err != nil {
	//		panic(err)
	//	}
	// init signals, block wait signals
	signalCH := InitSignal()
	HandleSignal(signalCH)
	// exit
	log.Info("comet stop")
}