1
我想使用Promises在node.js中运行mongod命令,以便数据库操作只有在mongodb进程启动后才能运行。我试了下我的手,但失败了:Bluebird Promise中的Nodejs exec mongodb命令
var Promise = require("bluebird");
var execAsync = Promise.promisify(require('child_process').exec);
execAsync("~/mongodb/bin/mongod").then(function(result){
console.log("started mongodb...");
}).catch(function(error){
console.log("error in starting mongodb..."+JSON.stringify(error));
});
有什么建议吗?
*但失败* - 你为什么这么认为? – thefourtheye
我看到这个过程已经开始,我无法看到日志中显示“已启动mongodb ...” – user3601166