forked from mongodb-js/mongodb-prebuilt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
33 lines (29 loc) · 1.19 KB
/
cli.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
'use strict';
var proc = require('child_process');
var path = require('path');
module.exports = function(exec_name) {
var debug = require('debug')('mongodb-prebuilt:' + exec_name);
var exec_path = require('./index').bin_path();
var exec_bin = path.resolve(exec_path, exec_name);
debug("exec_path: %s", exec_bin);
var child = proc.spawn(exec_bin, process.argv.slice(2), {stdio: 'inherit'});
child.on('close', function (code) {
process.exit(code);
});
var mongokiller = path.resolve(exec_path, '../../../binjs', 'mongokiller.js');
debug("mongokiller:", mongokiller, process.pid, child.pid);
var monitor_child;
if (process.platform === "win32") {
monitor_child = proc.spawn(
"cmd.exe",
[mongokiller, process.pid, child.pid],
{stdio: 'inherit', detached: false}
);
} else {
monitor_child = proc.spawn(
mongokiller,
[process.pid, child.pid],
{stdio: 'inherit', detached: false}
);
}
}