On MongoDB failures print 20 lines of stderr and print a special error if mongod failed to start due to incompatible version of glibc.

Catch stderr before 'exit' signal

Try to give a good error message on outdated glibc/libstdc++.

Simplify error reporting to two lines.

Print only last 20 lines of stderr.

Slightly better error message.
This commit is contained in:
Slava Kim
2013-09-23 17:47:29 -07:00
parent 4f4e5342eb
commit 63589300fe
2 changed files with 21 additions and 3 deletions

View File

@@ -172,7 +172,16 @@ exports.launch_mongo = function (app_dir, port, launch_callback, on_exit_callbac
callback && callback(err);
};
proc.on('exit', on_exit_callback);
var stderrOutput = '';
proc.stderr.setEncoding('utf8');
proc.stderr.on('data', function (data) {
stderrOutput += data;
});
proc.on('exit', function (code, signal) {
on_exit_callback(code, signal, stderrOutput);
});
proc.stdout.setEncoding('utf8');
proc.stdout.on('data', function (data) {

View File

@@ -628,11 +628,15 @@ exports.run = function (context, options) {
}
restartServer();
},
function (code, signal) { // On Mongo dead
function (code, signal, stderr) { // On Mongo dead
if (Status.shuttingDown) {
return;
}
console.log("Unexpected mongo exit code " + code + ". Restarting.");
// Print only last 20 lines of stderr.
stderr = stderr.split('\n').slice(-20).join('\n');
console.log(stderr + "Unexpected mongo exit code " + code + ". Restarting.\n");
// if mongo dies 3 times with less than 5 seconds between each,
// declare it failed and die.
@@ -645,6 +649,11 @@ exports.run = function (context, options) {
if (explanation === mongoExitCodes.EXIT_NET_ERROR)
console.log("\nCheck for other processes listening on port " + mongoPort +
"\nor other meteors running in the same project.");
if (!explanation && /GLIBC/i.test(stderr))
console.log("\nLooks like you are trying to run Meteor on old Linux " +
"distribution. Meteor only supports Linux with glibc " +
"version 2.9 and above. Try upgrading your distribution " +
"to the latest version.");
process.exit(1);
}
if (mongoErrorTimer)