Commit 8ac738bc authored by Antony Orlovsky's avatar Antony Orlovsky

Merge branch 'develop' into 'develop'

Added limits to compiler and task

See merge request !7
parents 3ac773da db872a57
......@@ -37,6 +37,18 @@ const CompilerSchema = new mongoose.Schema({
extensions: {
type: [String],
default: []
},
index: {
type: Number,
default: 0
},
cpuTimeLimit: {
type: Number,
default: 2
},
memoryLimit: {
type: String,
default: '1M'
}
});
......@@ -51,11 +63,11 @@ const Compiler = mongoose.connection.model('Compiler', CompilerSchema);
module.exports.model = Compiler;
module.exports.getAll = () => {
return Compiler.find({});
return Compiler.find({}).sort({index: 1});
};
module.exports.getMany = ids => {
return Compiler.findOne({_id: {$in: ids}});
return Compiler.find({_id: {$in: ids}});
};
module.exports.getShotForNames = names => {
......@@ -63,7 +75,7 @@ module.exports.getShotForNames = names => {
};
module.exports.get = id => {
return Compiler.findOne({_id: id})
return Compiler.findOne({_id: id});
};
module.exports.add = (name, displayedName, isProject, compileCommands, detectCommand, detectOutput, runCommand, forcedCompileOutputExtension) => {
......
......@@ -84,6 +84,10 @@ const TaskSchema = new mongoose.Schema({
type: Array,
default: []
},
useLimits: {
type: Boolean,
default: false
},
cpuTimeLimit: {
type: Number,
default: 2
......@@ -479,10 +483,11 @@ module.exports.setCompilers = (id, addCompilers, removeCompilers) => {
module.exports.setCompilerConfig = (id, compiler, config) => {
return Task.findOneAndUpdate({_id: id},
{
[`testerConfig.compilers.${compiler}.cpuTimeLimit`] : config.cpuTimeLimit || -1,
[`testerConfig.compilers.${compiler}.memoryLimit`]: config.memoryLimit || -1,
[`testerConfig.compilers.${compiler}.arguments`] : config.arguments || '',
[`testerConfig.compilers.${compiler}.compileProjectFileName`] : config.compileProjectFileName || ''
[`testerConfig.compilers.${compiler}.useLimits`] : config.useLimits,
[`testerConfig.compilers.${compiler}.cpuTimeLimit`] : config.cpuTimeLimit,
[`testerConfig.compilers.${compiler}.memoryLimit`]: config.memoryLimit,
[`testerConfig.compilers.${compiler}.arguments`] : config.arguments,
[`testerConfig.compilers.${compiler}.compileProjectFileName`] : config.compileProjectFileName
});
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment