remove main
This commit is contained in:
parent
b3575246bd
commit
9814217aee
|
@ -17,22 +17,15 @@ let gid = 0;
|
||||||
|
|
||||||
class Job {
|
class Job {
|
||||||
|
|
||||||
constructor({ runtime, files, args, stdin, timeouts, main, alias }) {
|
constructor({ runtime, files, args, stdin, timeouts, alias }) {
|
||||||
this.uuid = uuidv4();
|
this.uuid = uuidv4();
|
||||||
this.runtime = runtime;
|
this.runtime = runtime;
|
||||||
this.files = files;
|
this.files = files;
|
||||||
this.args = args;
|
this.args = args;
|
||||||
this.stdin = stdin;
|
this.stdin = stdin;
|
||||||
this.timeouts = timeouts;
|
this.timeouts = timeouts;
|
||||||
this.main = main;
|
|
||||||
this.alias = alias;
|
this.alias = alias;
|
||||||
|
|
||||||
let file_list = this.files.map(f => f.name);
|
|
||||||
|
|
||||||
if (!file_list.includes(this.main)) {
|
|
||||||
throw new Error(`Main file "${this.main}" will not be written to disk`);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.uid = config.runner_uid_min + uid;
|
this.uid = config.runner_uid_min + uid;
|
||||||
this.gid = config.runner_gid_min + gid;
|
this.gid = config.runner_gid_min + gid;
|
||||||
|
|
||||||
|
@ -171,7 +164,7 @@ class Job {
|
||||||
|
|
||||||
const run = await this.safe_call(
|
const run = await this.safe_call(
|
||||||
path.join(this.runtime.pkgdir, 'run'),
|
path.join(this.runtime.pkgdir, 'run'),
|
||||||
[this.main, ...this.args],
|
[this.files[0].name, ...this.args],
|
||||||
this.timeouts.run
|
this.timeouts.run
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// {"language":"python","version":"3.9.1","files":{"code.py":"print('hello world')"},"args":[],"stdin":"","compile_timeout":10, "run_timeout":3, "main": "code.py"}
|
// {"language":"python","version":"3.9.1","files":{"code.py":"print('hello world')"},"args":[],"stdin":"","compile_timeout":10, "run_timeout":3}
|
||||||
// {"success":true, "run":{"stdout":"hello world", "stderr":"", "error_code":0},"compile":{"stdout":"","stderr":"","error_code":0}}
|
// {"success":true, "run":{"stdout":"hello world", "stderr":"", "error_code":0},"compile":{"stdout":"","stderr":"","error_code":0}}
|
||||||
|
|
||||||
const { get_latest_runtime_matching_language_version } = require('../runtime');
|
const { get_latest_runtime_matching_language_version } = require('../runtime');
|
||||||
|
@ -55,8 +55,7 @@ module.exports = {
|
||||||
timeouts: {
|
timeouts: {
|
||||||
run: req.body.run_timeout,
|
run: req.body.run_timeout,
|
||||||
compile: req.body.compile_timeout
|
compile: req.body.compile_timeout
|
||||||
},
|
}
|
||||||
main: req.body.main
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await job.prime();
|
await job.prime();
|
||||||
|
|
|
@ -52,7 +52,6 @@ exports.handler = async function(argv){
|
||||||
language: argv.language,
|
language: argv.language,
|
||||||
version: argv['language-version'],
|
version: argv['language-version'],
|
||||||
files: files,
|
files: files,
|
||||||
main: path.basename(argv.file),
|
|
||||||
args: argv.args,
|
args: argv.args,
|
||||||
stdin,
|
stdin,
|
||||||
compile_timeout: argv.ct,
|
compile_timeout: argv.ct,
|
||||||
|
|
|
@ -194,10 +194,9 @@ Content-Type: application/json
|
||||||
This endpoint requests execution of some arbitrary code.
|
This endpoint requests execution of some arbitrary code.
|
||||||
- `language` (**required**) The language to use for execution, must be a string and must be installed.
|
- `language` (**required**) The language to use for execution, must be a string and must be installed.
|
||||||
- `version` (**required**) The version of the language to use for execution, must be a string containing a SemVer selector for the version or the specific version number to use.
|
- `version` (**required**) The version of the language to use for execution, must be a string containing a SemVer selector for the version or the specific version number to use.
|
||||||
- `files` (**required**) An array of files containing code or other data that should be used for execution.
|
- `files` (**required**) An array of files containing code or other data that should be used for execution. The first file in this array is considered the main file.
|
||||||
- `files[].name` (**required**) The name of the file to upload, must be a string containing no path.
|
- `files[].name` (**required**) The name of the file to upload, must be a string containing no path.
|
||||||
- `files[].content` (**required**) The content of the files to upload, must be a string containing text to write.
|
- `files[].content` (**required**) The content of the files to upload, must be a string containing text to write.
|
||||||
- `main` (**required**) The name of one of the files provided that should be considered the main source file which will be used as the entrypoint, must be a string and be the name of a file in `files`.
|
|
||||||
- `stdin` (**required**) The text to pass as stdin to the program. Must be a string, can be left blank.
|
- `stdin` (**required**) The text to pass as stdin to the program. Must be a string, can be left blank.
|
||||||
- `args` (**required**) The arguments to pass to the program. Must be an array.
|
- `args` (**required**) The arguments to pass to the program. Must be an array.
|
||||||
- `compile_timeout` (**required**) The maximum time allowed for the compile stage to finish before bailing out in milliseconds. Must be a number.
|
- `compile_timeout` (**required**) The maximum time allowed for the compile stage to finish before bailing out in milliseconds. Must be a number.
|
||||||
|
@ -213,7 +212,6 @@ This endpoint requests execution of some arbitrary code.
|
||||||
"content": "console.log(process.argv)"
|
"content": "console.log(process.argv)"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"main": "my_cool_code.js",
|
|
||||||
"stdin": "",
|
"stdin": "",
|
||||||
"args": [
|
"args": [
|
||||||
"1",
|
"1",
|
||||||
|
|
Loading…
Reference in New Issue