测试构建

This commit is contained in:
undefined committed 2020-05-10 17:03:16 +08:00
1 parent 27cfe81e31
commit 9156fa3a9b
6 files changed
+80 -48

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
const fs = require('fs');
const path = require('path');
exports.prebuild = async function prebuild() {
if (!fs.existsSync(path.resolve(__dirname, 'file', 'executorserver'))) {
if (!fs.existsSync(path.resolve(__dirname, 'file'))) {
fs.mkdirSync(path.resolve(__dirname, 'file'));
}
// TODO download executorserver
}
};
+6
View File
@@ -0,0 +1,6 @@
{
"name": "sandbox-linux",
"version": "1.0.0",
"os": "Linux",
"description": "Sandbox service for linux"
}
+24
View File
@@ -0,0 +1,24 @@
const os = require('os');
const path = require('path');
const child = require('child_process');
const p = child.spawn(path.resolve(os.tmpdir(), 'hydro', 'sandbox-linux-amd64', '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 };