javascript - Node.js: Get "Trying to open unclosed connection" when calling method from child process -
i'm getting "error: trying open unclosed connection," don't believe it's due db issue... , that's why i'm stumped. solutions error, reference db connection issues.
my goal here execute external process. if process closes other exit code 0, want email alert example.
i using child.on('close', function(code).... exit value external process (coming "code") if code !=0 want something... maybe rerun test... maybe call different method sends email, etc.
each time attempt call method, within child.on('close'), error "trying open unclosed connection." why i'm handling save action in same block.
code sample:
var spawn = require('child_process').spawn, child = spawn('sipp', ['-s', dnis,server, '-sn', scenario, '-m', '1','-i','127.0.0.1','-recv_timeout','1000']); } child.on('close',function(code){ if(code != 0){ call().emailalert(dnis, server, scenario, type, carrier); } var testresults = mongoose.model('test_results', testresultsschema); // saving results mongodb var result = new testresults({ testtype: type, dnis: dnis, server: server, result: code, carrier: carrier, date: date.now() }); result.save(function (err) {if (!err) {console.log ('successful save!')} else{console.log(err)}}); });
};
if remove:
if(code != 0){ call().emailalert(dnis, server, scenario, type, carrier); }
the error goes away. what's best way me capture exit code of process, , based on it, make call different method (i.e. email alert) in node.js?
i guess wrong. changed mongoose.connect mongoose.createconnection , specific error went away... unfortunately i'm left more errors. i'll open main question in different topic.
Comments
Post a Comment