-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
41 lines (37 loc) · 1.05 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const fs = require('fs');
const { fork } = require('child_process');
const path = require('path');
var filename = path.resolve(path.join('.', 'temp-config.conf'));
var conf = {
"applets": [{ container: '/', path: path.resolve(path.join('.', 'applets', 'ROOT')) }],
"protocols": [
{
"name": "http",
"port": 65531,
"listen": "0.0.0.0",
"ssl": false,
"cert": null,
"key": null
}
],
"errorTemplate": "./conf/errors.ejs"
}
fs.writeFile(filename, JSON.stringify(conf, null, 4), (err) => {
if (err) {
console.log("ERROR:", err);
return process.exit(1);
}
var task = fork("node bin/coffeecat.js", ["-c", filename], {
stdio: ['pipe', 'pipe', 'pipe', 'ipc']
});
setTimeout(() => {
if (task) task.kill();
fs.unlink(filename, (err) => {
if (err) {
console.log("ERROR:", err);
return process.exit(1);
}
process.exit(0);
});
}, 5000);
});