diff --git a/api/src/config.js b/api/src/config.js index bbd7ae9..84270aa 100644 --- a/api/src/config.js +++ b/api/src/config.js @@ -114,13 +114,6 @@ const options = [ 'https://github.com/engineer-man/piston/releases/download/pkgs/index', validators: [], }, - { - key: 'max_concurrent_jobs', - desc: 'Maximum number of concurrent jobs to run at one time', - default: 64, - parser: parse_int, - validators: [(x) => x > 0 || `${x} cannot be negative`] - } ]; logger.info(`Loading Configuration from environment`); diff --git a/api/src/job.js b/api/src/job.js index 712dcd8..683cda6 100644 --- a/api/src/job.js +++ b/api/src/job.js @@ -16,19 +16,6 @@ const job_states = { let uid = 0; let gid = 0; -let remainingJobSpaces = config.max_concurrent_jobs; -let jobQueue = []; - - -setInterval(()=>{ - // Every 10ms try resolve a new job, if there is an available slot - if(jobQueue.length > 0 && remainingJobSpaces > 0){ - jobQueue.shift()() - } -}, 10) - - - class Job { constructor({ runtime, files, args, stdin, timeouts, memory_limits }) { this.uuid = uuidv4(); @@ -61,15 +48,8 @@ class Job { } async prime() { - if(remainingJobSpaces < 1){ - logger.info(`Awaiting job slot uuid=${this.uuid}`) - await new Promise((resolve)=>{ - jobQueue.push(resolve) - }) - } - logger.info(`Priming job uuid=${this.uuid}`); - remainingJobSpaces--; + logger.debug('Writing files to job cache'); logger.debug(`Transfering ownership uid=${this.uid} gid=${this.gid}`); @@ -172,23 +152,21 @@ class Job { } }); - const exit_cleanup = async () => { + const exit_cleanup = () => { clear_timeout(kill_timeout); proc.stderr.destroy(); proc.stdout.destroy(); - - await this.cleanup_processes() }; - proc.on('exit', async (code, signal) => { - await exit_cleanup(); + proc.on('exit', (code, signal) => { + exit_cleanup(); resolve({stdout, stderr, code, signal, output }); }); - proc.on('error', async err => { - await exit_cleanup(); + proc.on('error', err => { + exit_cleanup(); reject({ error: err, stdout, stderr, output }); }); @@ -361,13 +339,11 @@ class Job { async cleanup() { logger.info(`Cleaning up job uuid=${this.uuid}`); + await this.cleanup_processes(); await this.cleanup_filesystem(); - - remainingJobSpaces++; } } - module.exports = { Job, }; diff --git a/docs/configuration.md b/docs/configuration.md index 16a5df0..1388e9d 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -145,12 +145,3 @@ default: https://github.com/engineer-man/piston/releases/download/pkgs/index ``` URL for repository index, where packages will be downloaded from. - -## Maximum Concurrent Jobs - -```yaml -key: PISTON_MAX_CONCURRENT_JOBS -default: 64 -``` - -Maximum number of jobs to run concurrently.