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

Merge branch 'develop' into 'develop'

Added limits to compiler and task

See merge request mirera/mirera-db!7
parents 3ac773da db872a57
...@@ -37,6 +37,18 @@ const CompilerSchema = new mongoose.Schema({ ...@@ -37,6 +37,18 @@ const CompilerSchema = new mongoose.Schema({
extensions: { extensions: {
type: [String], type: [String],
default: [] 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); ...@@ -51,11 +63,11 @@ const Compiler = mongoose.connection.model('Compiler', CompilerSchema);
module.exports.model = Compiler; module.exports.model = Compiler;
module.exports.getAll = () => { module.exports.getAll = () => {
return Compiler.find({}); return Compiler.find({}).sort({index: 1});
}; };
module.exports.getMany = ids => { module.exports.getMany = ids => {
return Compiler.findOne({_id: {$in: ids}}); return Compiler.find({_id: {$in: ids}});
}; };
module.exports.getShotForNames = names => { module.exports.getShotForNames = names => {
...@@ -63,7 +75,7 @@ module.exports.getShotForNames = names => { ...@@ -63,7 +75,7 @@ module.exports.getShotForNames = names => {
}; };
module.exports.get = id => { 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) => { module.exports.add = (name, displayedName, isProject, compileCommands, detectCommand, detectOutput, runCommand, forcedCompileOutputExtension) => {
......
...@@ -84,6 +84,10 @@ const TaskSchema = new mongoose.Schema({ ...@@ -84,6 +84,10 @@ const TaskSchema = new mongoose.Schema({
type: Array, type: Array,
default: [] default: []
}, },
useLimits: {
type: Boolean,
default: false
},
cpuTimeLimit: { cpuTimeLimit: {
type: Number, type: Number,
default: 2 default: 2
...@@ -479,10 +483,11 @@ module.exports.setCompilers = (id, addCompilers, removeCompilers) => { ...@@ -479,10 +483,11 @@ module.exports.setCompilers = (id, addCompilers, removeCompilers) => {
module.exports.setCompilerConfig = (id, compiler, config) => { module.exports.setCompilerConfig = (id, compiler, config) => {
return Task.findOneAndUpdate({_id: id}, return Task.findOneAndUpdate({_id: id},
{ {
[`testerConfig.compilers.${compiler}.cpuTimeLimit`] : config.cpuTimeLimit || -1, [`testerConfig.compilers.${compiler}.useLimits`] : config.useLimits,
[`testerConfig.compilers.${compiler}.memoryLimit`]: config.memoryLimit || -1, [`testerConfig.compilers.${compiler}.cpuTimeLimit`] : config.cpuTimeLimit,
[`testerConfig.compilers.${compiler}.arguments`] : config.arguments || '', [`testerConfig.compilers.${compiler}.memoryLimit`]: config.memoryLimit,
[`testerConfig.compilers.${compiler}.compileProjectFileName`] : config.compileProjectFileName || '' [`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