Пример #1
0
func createUnexecutedResult(nid int, jid string) *message.JobResult {
	result := new(message.JobResult)
	result.NID = nid
	result.JID = jid
	result.Stat = -1
	return result
}
Пример #2
0
func DoJobResultCheck(chk *message.JobCheck, conf *config.ServantConfig) *message.JobResult {
	result := new(message.JobResult)
	result.NID = chk.NID
	result.JID = chk.JID

	logPath := filepath.Join(conf.Dir.LogDir, "servant.log")
	endRecord, err := searchJobEndRecordFromLog(logPath, result.NID, result.JID)
	if err != nil || len(endRecord) == 0 {
		return createUnexecutedResult(chk.NID, chk.JID)
	}

	status, err := extractStatusFromRecord(endRecord)
	if err != nil || status == 0 {
		return createErrorResult(chk.NID, chk.JID)
	}
	result.Stat = status

	et, err := extractTimestampFromRecord(endRecord)
	if err != nil {
		return createErrorResult(chk.NID, chk.JID)
	}
	result.Et = et.Format(utctime.Default)

	rc, err := extractRCFromRecord(endRecord)
	if err != nil {
		return createErrorResult(chk.NID, chk.JID)
	}
	result.RC = rc

	joblog, err := searchLatestJoblog(conf.Dir.JoblogDir, chk.NID, chk.JID, et)
	if err != nil {
		return createErrorResult(chk.NID, chk.JID)
	}

	st, err := extractTimestampFromJoblog(joblog)
	if err != nil {
		return createErrorResult(chk.NID, chk.JID)
	}
	result.St = st.Format(utctime.Default)

	variable, err := extractVariableFromJoblog(joblog)
	if err != nil {
		return createErrorResult(chk.NID, chk.JID)
	}
	result.Var = variable

	return result
}
Пример #3
0
func createErrorResult(nid int, jid string) *message.JobResult {
	result := new(message.JobResult)
	result.NID = nid
	result.JID = jid
	return result
}