예제 #1
0
파일: wgf.go 프로젝트: Rickykurt/wgf
//启动http(fastcgi)服务器
func StartHttpServer() {

	//parse cli params
	flag.Visit(visitFlags)

	var basedir string
	basedir = cliArgs["basedir"]
	if "" == basedir {
		basedir, _ = os.Getwd()
	}

	var confFile string
	var pConf *conf.Conf
	confFile = basedir + "/conf/wgf.ini"
	pConf = conf.NewConf()
	pConf.ParseFile(confFile)

	//load conf file
	server := &sapi.Server{}
	server.Init(basedir, pConf)
}
예제 #2
0
파일: router.go 프로젝트: Rickykurt/wgf
func serverInit(pServer *sapi.Server) error {
	confDefaultAction = pServer.Conf.String("wgf.router.defaultAction", "index")
	confEnableRewrite = pServer.Conf.Bool("wgf.router.enableRewrite", true)

	confRouterFilePath = pServer.Conf.String("wgf.router.confFile", "router.ini")
	if confRouterFilePath[0] != '/' {
		confRouterFilePath = pServer.Confdir() + confRouterFilePath
	}

	confRouter = conf.NewConf()
	confRouter.ParseFile(confRouterFilePath)

	var err error
	for key, val := range confRouter.Data() {
		err = addRule(key, val)
		if nil != err {
			pServer.Log(fmt.Sprintf("router error when addRule, %s=%s, errors: %s", key, val, err.Error()))
		}
	}
	return nil
}