|
|
@ -28,7 +28,6 @@ async function connect () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
amqpConsumeChannel = await amqpConnection.createChannel(); |
|
|
|
amqpConsumeChannel = await amqpConnection.createChannel(); |
|
|
|
amqpConsumeChannel.prefetch(1); |
|
|
|
amqpConsumeChannel.prefetch(1); |
|
|
|
winston.debug('Winston test'); |
|
|
|
|
|
|
|
amqpConsumeChannel.consume('result', async (msg) => { |
|
|
|
amqpConsumeChannel.consume('result', async (msg) => { |
|
|
|
(async(msg) => { |
|
|
|
(async(msg) => { |
|
|
|
const data = msgPack.decode(msg.content); |
|
|
|
const data = msgPack.decode(msg.content); |
|
|
@ -99,12 +98,13 @@ async function connect () { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
module.exports.judge = async function (judge_state, problem, priority) { |
|
|
|
module.exports.judge = async function (judge_state, problem, priority) { |
|
|
|
let type, param, extraFile = null; |
|
|
|
let type, param, extraData = null; |
|
|
|
switch (problem.type) { |
|
|
|
switch (problem.type) { |
|
|
|
case 'submit-answer': |
|
|
|
case 'submit-answer': |
|
|
|
type = enums.ProblemType.AnswerSubmission; |
|
|
|
type = enums.ProblemType.AnswerSubmission; |
|
|
|
param = null; |
|
|
|
param = null; |
|
|
|
extraFile = 'static/uploads/answer/' + judge_state.code; |
|
|
|
let fs = Promise.promisifyAll(require('fs-extra')); |
|
|
|
|
|
|
|
extraData = await fs.readFileAsync(syzoj.model('file').resolvePath('answer', judge_state.code)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'interaction': |
|
|
|
case 'interaction': |
|
|
|
type = enums.ProblemType.Interaction; |
|
|
|
type = enums.ProblemType.Interaction; |
|
|
@ -128,19 +128,15 @@ module.exports.judge = async function (judge_state, problem, priority) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const req = { |
|
|
|
const content = { |
|
|
|
content: { |
|
|
|
taskId: judge_state.task_id, |
|
|
|
taskId: judge_state.task_id, |
|
|
|
testData: problem.id.toString(), |
|
|
|
testData: problem.id.toString(), |
|
|
|
type: type, |
|
|
|
type: type, |
|
|
|
priority: priority, |
|
|
|
priority: priority, |
|
|
|
param: param |
|
|
|
param: param |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
extraFileLocation: extraFile |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: parse extraFileLocation
|
|
|
|
amqpSendChannel.sendToQueue('judge', msgPack.encode({ content: content, extraData: extraData }), { priority: priority }); |
|
|
|
amqpSendChannel.sendToQueue('judge', msgPack.encode({ content: req.content, extraData: null }), { priority: priority }); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
connect(); |
|
|
|
connect(); |
|
|
|