From 63589300fedfec044c80d19f0da07ad88c54d772 Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Mon, 23 Sep 2013 17:47:29 -0700 Subject: [PATCH] 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. --- tools/mongo_runner.js | 11 ++++++++++- tools/run.js | 13 +++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tools/mongo_runner.js b/tools/mongo_runner.js index f40a438433..c39e2e64cf 100644 --- a/tools/mongo_runner.js +++ b/tools/mongo_runner.js @@ -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) { diff --git a/tools/run.js b/tools/run.js index 8ddc3dc2ed..542485a32a 100644 --- a/tools/run.js +++ b/tools/run.js @@ -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)