Exemplo n.º 1
0
func main() {

	l4g.LoadConfiguration("log4g.xml")

	ivr.InitIVRServer(8084)
	// ivr.InitDB("tcp(172.168.2.107:3306)", "root", "root01", "ivr")
}
Exemplo n.º 2
0
Arquivo: main.go Projeto: james4e/goim
func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	log.Info("logic[%s] start", Ver)
	perf.Init(Conf.PprofAddrs)
	// router rpc
	if err := InitRouter(); err != nil {
		log.Warn("router rpc current can't connect, retry")
	}
	MergeRoomCount()
	go SyncRoomCount()
	// logic rpc
	if err := InitRPC(NewDefaultAuther()); err != nil {
		panic(err)
	}
	if err := InitKafka(Conf.KafkaAddrs); err != nil {
		panic(err)
	}
	if err := InitHTTP(); err != nil {
		panic(err)
	}
	// block until a signal is received.
	InitSignal()
}
Exemplo n.º 3
0
// Configure the Application
func (a *Application) Configure() error {
	log.Debug("Reading logging config file")

	log.LoadConfiguration("./loggers.xml")

	log.Debug("Reading application config file")

	file, err := ioutil.ReadFile("./config.json")
	if err != nil {
		log.Error("Error opening config file: ", err)
		panic(err)
	}

	log.Info("Config Loaded:\n\n" + string(file))

	var config Config
	err = json.Unmarshal(file, &config)
	if err != nil {
		log.Error("Error parsing config file: ", err)
		panic(err)
	}

	debug, ok := config["debug"].(bool)
	if !ok {
		debug = false
	}

	a.Config = config
	a.Debug = debug

	return nil
}
Exemplo n.º 4
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")
}
Exemplo n.º 5
0
func TestWebManager(t *testing.T) {
	l4g.LoadConfiguration("../../config/logConfig.xml")

	configFile, readConfigFileErr := os.Open("../../config/overwall.config")
	if readConfigFileErr != nil {
		t.Fatal(readConfigFileErr)
	}
	decoder := json.NewDecoder(configFile)
	config := &Config{}
	decoder.Decode(&config)

	fmt.Printf("config info:\n%+v\n", config)

	opt := news.Option{}
	opt.SpeechFileDir = config.SpeechFileDir
	opt.SpeechCache = config.CacheSize
	opt.SentenceLen = config.OneSentenceLen
	opt.MaxGenVoiceTask = config.MaxGenVoiceTask
	opt.EasyreadUsername = config.EasyreadUsername
	opt.EasyreadPwd = config.EasyreadPwd
	opt.GenVoiceFile = true

	fmt.Printf("opt info:\n%+v\n", opt)

	newsManager := news.NewNewsManager(opt)
	webManager := NewWebManager(newsManager, "8787", "/home/noah/workspace/OverWall/config/chimes1.mp3")
	webManager.StartServer()
}
Exemplo n.º 6
0
func main() {

	runtime.GOMAXPROCS(runtime.NumCPU())
	//l4g.AddFilter("file", l4g.FINE, l4g.NewFileLogWriter("server.log", false))
	// creates a tcp listener
	l4g.LoadConfiguration("./conf/log4go.xml")
	tcpAddr, err := net.ResolveTCPAddr("tcp4", ":8989")
	checkError(err)
	listener, err := net.ListenTCP("tcp", tcpAddr)
	checkError(err)
	defer l4g.Close()
	// creates a server
	config := &gotcp.Config{
		PacketSendChanLimit:    20,
		PacketReceiveChanLimit: 20,
	}
	srv := gotcp.NewServer(config, &Callback{}, &echo.EchoProtocol{})

	// starts service
	go srv.Start(listener, time.Second)
	l4g.Debug("listening: %s", listener.Addr())
	//log.Println("listening:", listener.Addr())

	// catchs system signal
	chSig := make(chan os.Signal)
	signal.Notify(chSig, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR2) //, syscall.SIGINT, syscall.SIGTERM
	l4g.Trace("Signal: %s", <-chSig)
	//log.Println("Signal: ", <-chSig)

	// stops service
	srv.Stop()
}
Exemplo n.º 7
0
func main() {
	var (
		addr     *net.UDPAddr
		listener *net.UDPConn
		err      error
	)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	if addr, err = net.ResolveUDPAddr("udp4", Conf.Bind); err != nil {
		log.Error("net.ResolveUDPAddr(\"udp4\", \"%s\") error(%v)", Conf.Bind, err)
		return
	}

	if listener, err = net.ListenUDP("udp4", addr); err != nil {
		log.Error("net.ListenUDP(\"udp4\", \"%v\") error(%v)", addr, err)
		return
	}
	defer listener.Close()

	if Debug {
		log.Debug("start udp listen: \"%s\"", Conf.Bind)
	}

	//N core accept
	for i := 0; i < Conf.MaxProc; i++ {
		go acceptUDP(listener)
	}
	//wait
	InitSignal()
}
Exemplo n.º 8
0
func loadLog4goConfig() {
	log4go.Debug("Loading configuration")
	_, err := os.Stat(logname)
	if os.IsNotExist(err) {
		return
	}
	log4go.LoadConfiguration(logname)
}
Exemplo n.º 9
0
func NoTestQueryLogisticsInfo(t *testing.T) {
	l4g.LoadConfiguration("../config/logConfig.xml")
	logisticsInfo, err := Query("shentong", "668031148649")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(logisticsInfo)
}
Exemplo n.º 10
0
func main() {
	l4g.LoadConfiguration("./conf/log4go.xml")
	if beego.RunMode == "dev" {
		beego.DirectoryIndex = true
		beego.StaticDir["/swagger"] = "swagger"
	}
	beego.Run()
}
Exemplo n.º 11
0
func main() {
	// Load the configuration (isn't this easy?)
	l4g.LoadConfiguration("example.xml")

	// And now we're ready!
	l4g.Finest("This will only go to those of you really cool UDP kids!  If you change enabled=true.")
	l4g.Debug("Oh no!  %d + %d = %d!", 2, 2, 2+2)
	l4g.Info("About that time, eh chaps?")
}
Exemplo n.º 12
0
Arquivo: main.go Projeto: hosangee/alf
func main() {
	var err error
	flag.Parse()

	log.LoadConfiguration("logging.xml")

	// Load configuration
	alfConfig, err := config.NewConfig(*configPath)
	if err != nil {
		log.Error("Error parsing configuration: ", err.Error())
		os.Exit(1)
	}

	// Connect to the database
	alfDb := db.NewDB()
	err = alfDb.Connect(alfConfig.DbUrl)
	defer alfDb.Close()

	if err != nil {
		log.Error("Error connecting to DB: ", err.Error())
		os.Exit(1)
	}

	// Get all hosts, and all checks
	var hosts []db.Host
	err = alfDb.Hosts.FindAll(&hosts)
	if err != nil {
		log.Error("Failed to get hosts: ", err.Error())
		os.Exit(1)
	}
	log.Debug("Hosts: %v", hosts)

	var tasks []db.Task
	err = alfDb.Tasks.FindAll(&tasks)
	if err != nil {
		log.Error("Failed to get tasks: ", err.Error())
		os.Exit(1)
	}
	log.Debug("tasks: %v", tasks)

	// Run every task on every host
	for _, host := range hosts {
		for _, task := range tasks {
			runner := NewRunner(&host, &task, alfDb)
			// Launch runner in its own goroutine
			go runner.run()
		}

	}

	// Run HTTP API handlers
	httpService := http.NewHttpService(alfConfig.BindAddress, alfDb)
	go httpService.Start()

	// Block forever, exit with a SIGINT
	select {}
}
Exemplo n.º 13
0
func main() {
	// init cmd args
	flag.Parse()
	// init config
	if err := initConfig(); err != nil {
		os.Exit(termExit)
	}
	// init log
	log.LoadConfiguration(conf.Log)
	defer log.Close()
	if len(conf.Sentinel) == 0 {
		// set to zk
		log.Error("conf.Sentinel don't have any sentinel addr")
		time.Sleep(logWait)
		os.Exit(retryExit)
	}
	log.Info("sentinels: \"%v\", master: \"%s\"", conf.Sentinel, conf.Master)
	// init sentinel addrs
	for _, addr := range conf.Sentinel {
		sentinelList.PushBack(addr)
	}
	redisConn := sentinel()
	if redisConn == nil {
		log.Error("sentinel can't connect")
		time.Sleep(logWait)
		os.Exit(retryExit)
	}
	defer redisConn.Close()
	// master redis
	redisMaster := masterAddr(redisConn)
	log.Debug("redis master: \"%s\"", redisMaster)
	isMaster := checkRole(redisMaster, roleMaster)
	if isMaster {
		refreshSentinel(redisConn)
	} else {
		log.Warn("abort the mission, master not ok")
		time.Sleep(logWait)
		os.Exit(retryExit)
	}
	// set to zk
	zkConn := zkDial()
	if zkConn == nil {
		log.Error("zookeeper can't connect")
		time.Sleep(logWait)
		os.Exit(retryExit)
	}
	defer zkConn.Close()
	if err := zkData(zkConn, redisMaster); err != nil {
		log.Error("zookeeper set data failed")
		time.Sleep(logWait)
		os.Exit(retryExit)
	}
	time.Sleep(logWait)
	os.Exit(okExit)
}
Exemplo n.º 14
0
// 爬虫主程序
func main() {
	// l4g的配置文件
	l4g.LoadConfiguration(SPIDER_LOGCONF_XML)

	// refer : http://www.01happy.com/golang-command-line-arguments/
	var confPath string
	var logPath string
	var printVer bool

	flag.StringVar(&confPath, "c", "../../conf", "config file path")
	flag.StringVar(&logPath, "l", "../../log", "log file path")
	flag.BoolVar(&printVer, "v", false, "print version")

	flag.Parse()

	if printVer {
		utils.PrintVersion()
		os.Exit(0)
	}

	l4g.Info("Hi, dash's %s is running...\n", "go_mini_spider")

	confFile := confPath + "/" + SPIDER_CONFIG_FILE
	conf, err := conf.InitConf(confFile)
	if err != nil {
		l4g.Error("read spider config failed, err [%s]", err)
		SlowExit()
	}

	var seedUrls []string
	// read and parse json,相对路径
	b, err := ioutil.ReadFile(confPath + "/" + conf.UrlListFile)
	if err != nil {
		l4g.Error("readfile err[%s]", err)
		SlowExit()
	}
	//json to []string
	if err := json.Unmarshal(b, &seedUrls); err != nil {
		l4g.Error("parse json err[%s]", err)
		SlowExit()
	}

	//GOMAXPROCS设置
	runtime.GOMAXPROCS(runtime.NumCPU())

	// 启动爬虫
	spider := spider.NewSpider(seedUrls, conf, confPath)
	spider.Start()
	// 等待任务完成
	spider.Wait()

	time.Sleep(1 * time.Second)
}
Exemplo n.º 15
0
func NoTestUpdateAndGetChangedLogistics(t *testing.T) {
	l4g.LoadConfiguration("../config/logConfig.xml")
	service, err := NewLogisticsService("../../db/pilogistics.db")
	if err != nil {
		t.Fatal(err)
	}
	logisticsCh := make(chan *ChangedLogisticsInfo, 1)
	go service.UpdateAndGetChangedLogistics(logisticsCh)
	for changedInfo := range logisticsCh {
		t.Log("username:", changedInfo.Username)
		for _, rec := range changedInfo.NewRecords {
			t.Log(rec)
		}
	}

}
Exemplo n.º 16
0
Arquivo: main.go Projeto: dulumao/goim
func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	if Conf.Type == ProtoTCP {
		initTCP()
	} else if Conf.Type == ProtoWebsocket {
		initWebsocket()
	} else if Conf.Type == ProtoWebsocketTLS {
		initWebsocketTLS()
	}
}
Exemplo n.º 17
0
func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	perf.Init(Conf.PprofBind)
	if Conf.Type == ProtoTCP {
		initTCP()
	} else if Conf.Type == ProtoWebsocket {
		initWebsocket()
	}
	time.Sleep(10 * time.Second)
}
Exemplo n.º 18
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")
}
Exemplo n.º 19
0
func main() {
	logger.LoadConfiguration("logging.xml")
	logger.Trace("main start")

	logger.Trace("CPU NUM: %d", runtime.NumCPU())
	runtime.GOMAXPROCS(runtime.NumCPU())

	//static directories
	http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("./css/"))))
	http.Handle("/js/", http.StripPrefix("/js/", http.FileServer(http.Dir("./js/"))))
	http.Handle("/img/", http.StripPrefix("/img/", http.FileServer(http.Dir("./img/"))))

	handler.InitRoutes()

	http.HandleFunc("/", handler.RouteHandler)
	http.ListenAndServe(":8080", nil)
}
Exemplo n.º 20
0
func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	log.LoadConfiguration(Conf.Log)
	runtime.GOMAXPROCS(runtime.NumCPU())
	if err := InitComet(Conf.Comets); err != nil {
		panic(err)
	}
	InitPush()
	if err := InitKafka(); err != nil {
		panic(err)
	}
	// block until a signal is received.
	InitSignal()
}
Exemplo n.º 21
0
func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	log.Info("comet[%s] start", Ver)
	perf.Init(Conf.PprofBind)
	// logic rpc
	if err := InitLogicRpc(Conf.LogicAddr); err != nil {
		log.Warn("logic rpc current can't connect, retry")
	}
	// new server
	buckets := make([]*Bucket, Conf.Bucket)
	for i := 0; i < Conf.Bucket; i++ {
		buckets[i] = NewBucket(Conf.Channel, Conf.Room, Conf.RoomChannel, Conf.CliProto, Conf.SvrProto)
	}
	round := NewRound(Conf.ReadBuf, Conf.WriteBuf, Conf.Timer, Conf.TimerSize)
	operator := new(DefaultOperator)
	DefaultServer = NewServer(buckets, round, operator)
	if err := InitTCP(); err != nil {
		panic(err)
	}
	if err := InitWebsocket(); err != nil {
		panic(err)
	}
	if Conf.WebsocketTLSOpen {
		if err := InitWebsocketWithTLS(); err != nil {
			panic(err)
		}
	}
	if err := InitHTTP(); err != nil {
		panic(err)
	}
	// start rpc
	if err := InitRPCPush(); err != nil {
		panic(err)
	}
	// block until a signal is received.
	InitSignal()
}
Exemplo n.º 22
0
Arquivo: main.go Projeto: hushi55/Grep
func main() {

	flag.Parse()
	if err := InitConfig(); err != nil {
		fmt.Printf("init err: %s", err)
		panic(err)
	}

	log.LoadConfiguration(Conf.Log)
	defer log.Close()

	// init evnet and shutdown
	InitEvent()
	defer ShutdownEvent()

	SyncDaemon()

	signal.InitSignal(reload)
}
Exemplo n.º 23
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()
	l4g.LoadConfiguration(*logConfig)
	l4g.Debug("MAXPROCS: %d", runtime.GOMAXPROCS(0))
	defer time.Sleep(2 * time.Second) // make sure log4go output the log
	piAssistant := NewPiAssistant()

	piAssistant.ServiceMgr.AddService(&pidownloader.PiDownloader{})
	piAssistant.ServiceMgr.AddService(&logistics.LogisticsService{})
	piAssistant.ServiceMgr.AddService(&aqi.AqiService{})
	piAssistant.ServiceMgr.AddService(&foodprice.FoodPriceService{})

	if initErr := piAssistant.Init(*configPath); initErr != nil { //"....//config/pidownloader.conf"
		l4g.Error("PiAssistant init failed: %v", initErr)
		return
	}
	piAssistant.StartService()
}
Exemplo n.º 24
0
Arquivo: main.go Projeto: hushi55/Grep
func main() {

	flag.Parse()
	if err := InitConfig(); err != nil {
		fmt.Printf("init err: %s", err)
		panic(err)
	}

	log.LoadConfiguration(Conf.Log)
	defer log.Close()

	// init evnet and shutdown
	InitEvent()
	defer ShutdownEvent()

	StartMongoReplica()

	StartCheckpointDeamon()

	InitSignal()
}
Exemplo n.º 25
0
func TestPiAssistant(t *testing.T) {
	xmpp.Debug = false
	aqi.Debug = true
	logistics.Debug = true
	simsimi.Debug = true
	speech2text.Debug = true
	foodprice.Debug = true
	runtime.GOMAXPROCS(runtime.NumCPU())
	l4g.LoadConfiguration("../../config/logConfig.xml")
	defer time.Sleep(2 * time.Second)
	piAssistant := NewPiAssistant()
	piAssistant.ServiceMgr.AddService(&pidownloader.PiDownloader{})
	piAssistant.ServiceMgr.AddService(&logistics.LogisticsService{})
	piAssistant.ServiceMgr.AddService(&aqi.AqiService{})
	piAssistant.ServiceMgr.AddService(&foodprice.FoodPriceService{})

	if initErr := piAssistant.Init("../../config/piassistant.conf"); initErr != nil {
		t.Fatal("init error:", initErr)
	}
	piAssistant.StartService()
}
Exemplo n.º 26
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")
}
Exemplo n.º 27
0
Arquivo: main.go Projeto: sf100/goim
func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	log.Info("router[%s] start", VERSION)
	// start prof
	perf.Init(Conf.PprofBind)
	// start rpc
	buckets := make([]*Bucket, Conf.Bucket)
	for i := 0; i < Conf.Bucket; i++ {
		buckets[i] = NewBucket(Conf.Session, Conf.Server, Conf.Cleaner)
	}
	if err := InitRPC(buckets); err != nil {
		panic(err)
	}
	// block until a signal is received.
	InitSignal()
}
Exemplo n.º 28
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")
}
Exemplo n.º 29
0
func main() {
	flag.Parse()
	if err := InitConfig(); err != nil {
		panic(err)
	}
	runtime.GOMAXPROCS(Conf.MaxProc)
	log.LoadConfiguration(Conf.Log)
	defer log.Close()
	log.Info("comet[%s] start", Ver)
	perf.Init(Conf.PprofBind)
	if err := InitRSA(); err != nil {
		panic(err)
	}
	// new server
	buckets := make([]*Bucket, Conf.Bucket)
	for i := 0; i < Conf.Bucket; i++ {
		buckets[i] = NewBucket(Conf.Channel, Conf.CliProto, Conf.SvrProto)
	}
	round := NewRound(Conf.ReadBuf, Conf.WriteBuf, Conf.Timer, Conf.TimerSize, Conf.Session, Conf.SessionSize)
	codec := new(BinaryServerCodec)
	operator := new(DefaultOperator)
	cryptor := NewDefaultCryptor()
	DefaultServer = NewServer(buckets, round, codec, operator, cryptor)
	if err := InitTCP(); err != nil {
		panic(err)
	}
	if err := InitWebsocket(); err != nil {
		panic(err)
	}
	if err := InitHttpPush(); err != nil {
		panic(err)
	}
	// start rpc
	if err := InitRPCPush(); err != nil {
		panic(err)
	}
	// block until a signal is received.
	InitSignal()
}
Exemplo n.º 30
0
func main() {
	//logConfig := new(string)
	//*logConfig = "../../config/logConfig.xml"
	//configPath := new(string)
	//*configPath = "../../config/overwall.config"

	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()
	l4g.LoadConfiguration(*logConfig)
	l4g.Debug("MAXPROCS: %d", runtime.GOMAXPROCS(0))
	defer time.Sleep(2 * time.Second) // make sure log4go output the log

	configFile, readConfigFileErr := os.Open(*configPath)
	if readConfigFileErr != nil {
		l4g.Error("Read config error: %s", readConfigFileErr.Error())
		return
	}
	decoder := json.NewDecoder(configFile)
	config := &web.Config{}
	decoder.Decode(&config)

	l4g.Info("Config info: %+v", config)

	opt := news.Option{}
	opt.SpeechFileDir = config.SpeechFileDir
	opt.SpeechCache = config.CacheSize
	opt.SentenceLen = config.OneSentenceLen
	opt.MaxGenVoiceTask = config.MaxGenVoiceTask
	opt.EasyreadUsername = config.EasyreadUsername
	opt.EasyreadPwd = config.EasyreadPwd
	opt.GenVoiceFile = true

	newsManager := news.NewNewsManager(opt)
	webManager := web.NewWebManager(newsManager, "8787", config)
	webManager.StartServer()
}