Reputation: 11797
The odd thing is this same code has worked previously. It seems that when I run the below now, I get no callback. None of the console logs work. However if I run "ls" instead of mongo for example it works fine, similarly if I write something like mongod -gfsssl (which should show an error) I do indeed get an error. Also if I run the same command as below in my terminal, it runs fine.
var sys = require('sys');
var exec = require('child_process').exec;
var nodemon = require('nodemon');
exec('mongod --dbpath="./data"', function(error, stdout, stderr) {
console.log(stderr);
console.log(error);
console.log(stdout);
nodemon({
script: 'app/server.js',
ext: 'js'
});
nodemon.on('start', function () {
console.log('App has started');
}).on('quit', function () {
console.log('App has quit');
}).on('restart', function (files) {
console.log('App restarted due to: ', files);
});
});
Upvotes: 0
Views: 209
Reputation: 106698
Are you sure that mongod
puts itself in the background after executing that command? It sounds like it's running in the foreground, causing the process to never exit (which is why your callback is never called).
Upvotes: 1