示例#1
0
func LoadPuppeteerConf(confPath string) *PuppeteerConf {
	var ret *PuppeteerConf
	confInfo, err := ppioutil.ParseIni(confPath)

	if nil == err {
		poolDir, poolOk := confInfo[POOL_DIR]
		queueDir, queueOk := confInfo[QUEUE_DIR]
		phantomBin, binOk := confInfo[PHANTOMJS_BIN]
		js, jsOk := confInfo[JS]
		maxProcStr, procOk := confInfo[MAX_PROC]
		logFile, logOk := confInfo[LOG_FILE]
		expireStr, expireOk := confInfo[EXPIRE]

		if poolOk && queueOk && binOk && jsOk && procOk && logOk && expireOk {
			if maxProc, err := strconv.ParseUint(maxProcStr, 10, 8); nil == err {
				ret = new(PuppeteerConf)
				ret.PoolDir = poolDir
				ret.QueueDir = queueDir
				ret.PhantomJSBin = phantomBin
				ret.JS = js
				ret.LogFile = logFile
				ret.MaxProc = uint8(maxProc)
				ret.Expire = EXPIRE_DEFAULT
				expire, err := strconv.ParseInt(expireStr, 10, 64)
				if nil == err && 0 < expire {
					ret.Expire = expire
				}
			}
		}
	}

	return ret
}
示例#2
0
func ReadJob(jobFile string) map[string]string {
	jobInfo, err := ppioutil.ParseIni(jobFile)

	if nil != err {
		return nil
	}

	return jobInfo
}