测试:judger封装为模块

This commit is contained in:
undefined committed 2020-05-08 12:28:04 +08:00
1 parent 5d7f57334f
commit 6134a16f8c
8 files changed
+305 -30

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
{
"name": "sandbox-linux",
"version": "1.0.0",
"os": "Linux",
"description": "Sandbox service for linux"
}
+23
View File
@@ -0,0 +1,23 @@
const os = require('os');
const child = require('child_process');
const p = child.spawn(path.resolve(os.tmpdir(), 'hydro', 'sandbox-linux', 'executorserver', ['-silent']);
if (!p.stdout) throw new Error('Cannot start executorserver');
else {
p.stdout.on('data', (data) => {
const s = data.toString();
console.log(s.substr(0, s.length - 1));
});
p.stderr.on('data', (data) => {
const s = data.toString();
console.log(s.substr(0, s.length - 1));
});
}
p.on('error', (error) => console.error(error));
async function stop() {
p.emit('exit');
}
module.exports = { stop };