Compare commits
No commits in common. "09eb9e4d9098dc1218f2358a83ff602080fb68c6" and "e767a6eafc4f432e5b66330a6698838ff269108a" have entirely different histories.
09eb9e4d90
...
e767a6eafc
|
@ -50,7 +50,6 @@ const SIGNALS = [
|
||||||
function get_job(job_info, available_runtimes) {
|
function get_job(job_info, available_runtimes) {
|
||||||
let {
|
let {
|
||||||
language,
|
language,
|
||||||
version,
|
|
||||||
args,
|
args,
|
||||||
stdin,
|
stdin,
|
||||||
files,
|
files,
|
||||||
|
@ -80,10 +79,8 @@ function get_job(job_info, available_runtimes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rt = available_runtimes.find(
|
const rt = available_runtimes.find(rt =>
|
||||||
rt =>
|
[...rt.aliases, rt.language].includes(rt.language)
|
||||||
[...rt.aliases, rt.language].includes(language) &&
|
|
||||||
(version === rt.version || version === '*')
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (rt === undefined) {
|
if (rt === undefined) {
|
||||||
|
|
|
@ -43,22 +43,7 @@ expressWs(app);
|
||||||
`nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames`
|
`nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames`
|
||||||
)
|
)
|
||||||
.toString();
|
.toString();
|
||||||
const runtime_names_unordered = JSON.parse(runtimes_data);
|
const runtime_names = JSON.parse(runtimes_data);
|
||||||
|
|
||||||
const mainstream_runtimes_data = cp
|
|
||||||
.execSync(
|
|
||||||
`nix eval --json ${config.flake_path}#pistonMainstreamRuntimes`
|
|
||||||
)
|
|
||||||
.toString();
|
|
||||||
const mainstream_runtimes = JSON.parse(mainstream_runtimes_data).filter(runtime =>
|
|
||||||
runtime_names_unordered.includes(runtime)
|
|
||||||
);
|
|
||||||
const runtime_names = [
|
|
||||||
...mainstream_runtimes,
|
|
||||||
...runtime_names_unordered.filter(
|
|
||||||
runtime => !mainstream_runtimes.includes(runtime)
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
logger.info('Loading the runtimes from the flakes');
|
logger.info('Loading the runtimes from the flakes');
|
||||||
const runtimes = runtime_names.map(runtime_name => {
|
const runtimes = runtime_names.map(runtime_name => {
|
||||||
|
|
|
@ -28,9 +28,6 @@ setInterval(() => {
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
class Job {
|
class Job {
|
||||||
#active_timeouts;
|
|
||||||
#active_parent_processes;
|
|
||||||
|
|
||||||
constructor({ runtime, files, args, stdin, timeouts, memory_limits }) {
|
constructor({ runtime, files, args, stdin, timeouts, memory_limits }) {
|
||||||
this.uuid = uuidv4();
|
this.uuid = uuidv4();
|
||||||
|
|
||||||
|
@ -52,9 +49,6 @@ class Job {
|
||||||
this.stdin += '\n';
|
this.stdin += '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#active_timeouts = [];
|
|
||||||
this.#active_parent_processes = [];
|
|
||||||
|
|
||||||
this.timeouts = timeouts;
|
this.timeouts = timeouts;
|
||||||
this.memory_limits = memory_limits;
|
this.memory_limits = memory_limits;
|
||||||
|
|
||||||
|
@ -119,28 +113,6 @@ class Job {
|
||||||
this.logger.debug('Primed job');
|
this.logger.debug('Primed job');
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_cleanup() {
|
|
||||||
for (const timeout of this.#active_timeouts) {
|
|
||||||
clear_timeout(timeout);
|
|
||||||
}
|
|
||||||
this.#active_timeouts = [];
|
|
||||||
this.logger.debug('Cleared the active timeouts');
|
|
||||||
|
|
||||||
for (const proc of this.#active_parent_processes) {
|
|
||||||
proc.stderr.destroy();
|
|
||||||
if (!proc.stdin.destroyed) {
|
|
||||||
proc.stdin.end();
|
|
||||||
proc.stdin.destroy();
|
|
||||||
}
|
|
||||||
proc.stdout.destroy();
|
|
||||||
}
|
|
||||||
this.#active_parent_processes = [];
|
|
||||||
this.logger.debug('Destroyed parent processes writables');
|
|
||||||
|
|
||||||
this.cleanup_processes();
|
|
||||||
this.logger.debug(`Finished exit cleanup`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async safe_call(file, args, timeout, memory_limit, eventBus = null) {
|
async safe_call(file, args, timeout, memory_limit, eventBus = null) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const nonetwork = config.disable_networking ? ['nosocket'] : [];
|
const nonetwork = config.disable_networking ? ['nosocket'] : [];
|
||||||
|
@ -177,8 +149,6 @@ class Job {
|
||||||
detached: true, //give this process its own process group
|
detached: true, //give this process its own process group
|
||||||
});
|
});
|
||||||
|
|
||||||
this.#active_parent_processes.push(proc);
|
|
||||||
|
|
||||||
if (eventBus === null) {
|
if (eventBus === null) {
|
||||||
proc.stdin.write(this.stdin);
|
proc.stdin.write(this.stdin);
|
||||||
proc.stdin.end();
|
proc.stdin.end();
|
||||||
|
@ -200,7 +170,6 @@ class Job {
|
||||||
process.kill(proc.pid, 'SIGKILL');
|
process.kill(proc.pid, 'SIGKILL');
|
||||||
}, timeout)) ||
|
}, timeout)) ||
|
||||||
null;
|
null;
|
||||||
this.#active_timeouts.push(kill_timeout);
|
|
||||||
|
|
||||||
proc.stderr.on('data', async data => {
|
proc.stderr.on('data', async data => {
|
||||||
if (eventBus !== null) {
|
if (eventBus !== null) {
|
||||||
|
@ -226,14 +195,24 @@ class Job {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const exit_cleanup = () => {
|
||||||
|
clear_timeout(kill_timeout);
|
||||||
|
|
||||||
|
proc.stderr.destroy();
|
||||||
|
proc.stdout.destroy();
|
||||||
|
|
||||||
|
this.cleanup_processes();
|
||||||
|
this.logger.debug(`Finished exit cleanup`);
|
||||||
|
};
|
||||||
|
|
||||||
proc.on('exit', (code, signal) => {
|
proc.on('exit', (code, signal) => {
|
||||||
this.exit_cleanup();
|
exit_cleanup();
|
||||||
|
|
||||||
resolve({ stdout, stderr, code, signal, output });
|
resolve({ stdout, stderr, code, signal, output });
|
||||||
});
|
});
|
||||||
|
|
||||||
proc.on('error', err => {
|
proc.on('error', err => {
|
||||||
this.exit_cleanup();
|
exit_cleanup();
|
||||||
|
|
||||||
reject({ error: err, stdout, stderr, output });
|
reject({ error: err, stdout, stderr, output });
|
||||||
});
|
});
|
||||||
|
@ -452,7 +431,7 @@ class Job {
|
||||||
async cleanup() {
|
async cleanup() {
|
||||||
this.logger.info(`Cleaning up job`);
|
this.logger.info(`Cleaning up job`);
|
||||||
|
|
||||||
this.exit_cleanup(); // Run process janitor, just incase there are any residual processes somehow
|
this.cleanup_processes(); // Run process janitor, just incase there are any residual processes somehow
|
||||||
await this.cleanup_filesystem();
|
await this.cleanup_filesystem();
|
||||||
|
|
||||||
remaining_job_spaces++;
|
remaining_job_spaces++;
|
||||||
|
|
|
@ -65,13 +65,6 @@
|
||||||
"bash-only" = runtimeList ["bash"];
|
"bash-only" = runtimeList ["bash"];
|
||||||
"none" = { };
|
"none" = { };
|
||||||
};
|
};
|
||||||
pistonMainstreamRuntimes = [
|
|
||||||
"mono-csharp"
|
|
||||||
"python3"
|
|
||||||
"node-javascript"
|
|
||||||
"node-typescript"
|
|
||||||
"mono-basic"
|
|
||||||
];
|
|
||||||
|
|
||||||
legacyPackages."${system}" = rec {
|
legacyPackages."${system}" = rec {
|
||||||
nosocket = (import ./nosocket { inherit pkgs; }).package;
|
nosocket = (import ./nosocket { inherit pkgs; }).package;
|
||||||
|
|
|
@ -7,8 +7,6 @@ in piston.mkRuntime {
|
||||||
|
|
||||||
aliases = [
|
aliases = [
|
||||||
"py2"
|
"py2"
|
||||||
"python"
|
|
||||||
"py"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
run = ''
|
run = ''
|
||||||
|
@ -24,4 +22,4 @@ in piston.mkRuntime {
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
|
@ -8,7 +8,6 @@ in piston.mkRuntime {
|
||||||
aliases = [
|
aliases = [
|
||||||
"py3"
|
"py3"
|
||||||
"py"
|
"py"
|
||||||
"python"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
run = ''
|
run = ''
|
||||||
|
@ -24,4 +23,4 @@ in piston.mkRuntime {
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
Loading…
Reference in New Issue