forked from bagusindrayana/alpaca_cpp_node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd.js
31 lines (25 loc) · 768 Bytes
/
cmd.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
const dotenv = require('dotenv');
dotenv.config();
//change this
const alpcaPath = process.env.COMMAND_PATH;
const alpcaModel = process.env.MODEL_PATH;
var spawn = require('child_process').spawn;
var cmd = spawn(alpcaPath + " -m " + alpcaModel, [], { shell: true });
process.stdin.pipe(cmd.stdin);
cmd.stdout.on('data', function (data) {
process.stdout.write(`${data.toString()}`);
});
cmd.stderr.on('data', function (data) {
process.stdout.write(`${data.toString()}`);
});
cmd.on('exit', function (code) {
console.log('exit code: ' + code);
});
process.on('SIGINT', function() {
console.log("Caught interrupt signal");
cmd.kill('SIGINT');
});
process.on('exit', function() {
console.log("Caught exit signal");
cmd.kill('SIGINT');
});