Skip to content

Commit

Permalink
fix: spawn ETXTBSY error in Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Jun 7, 2017
1 parent d2f8860 commit 46b25f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cache:
yarn: true
directories:
- node_modules
- $HOME/.mongodb-prebuilt
- $HOME/.mongodb-binaries
notifications:
email: true
node_js:
Expand Down
16 changes: 9 additions & 7 deletions src/util/MongoInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type MongodOps = {
debug?: boolean,
};

export default class BinRunner {
export default class MongodbInstance {
static childProcessList: ChildProcess[] = [];
opts: MongodOps;
debug: Function;
Expand Down Expand Up @@ -92,7 +92,9 @@ export default class BinRunner {
}

launchMongod(mongoBin: string): ChildProcess {
const childProcess = spawnChild(mongoBin, this.prepareCommandArgs(), this.opts.spawn);
const spawnOpts = this.opts.spawn || {};
if (!spawnOpts.stdio) spawnOpts.stdio = 'ignore';
const childProcess = spawnChild(mongoBin, this.prepareCommandArgs(), spawnOpts);
childProcess.stderr.on('data', this.stderrHandler.bind(this));
childProcess.stdout.on('data', this.stdoutHandler.bind(this));
childProcess.on('close', this.closeHandler.bind(this));
Expand All @@ -103,11 +105,11 @@ export default class BinRunner {

launchKiller(parentPid: number, childPid: number): ChildProcess {
// spawn process which kills itself and mongo process if current process is dead
const killer = spawnChild(process.argv[0], [
path.resolve(__dirname, 'mongo_killer.js'),
parentPid.toString(),
childPid.toString(),
]);
const killer = spawnChild(
process.argv[0],
[path.resolve(__dirname, 'mongo_killer.js'), parentPid.toString(), childPid.toString()],
{ stdio: 'ignore' }
);

return killer;
}
Expand Down

0 comments on commit 46b25f1

Please sign in to comment.