mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
findMongoPids: use pgrep where available
ps corrupts some non-ASCII characters on OS X. pgrep doesn't, but isn't available everywhere. Fixes #3999.
This commit is contained in:
@@ -124,8 +124,26 @@ if (process.platform === 'win32') {
|
||||
var fut = new Future;
|
||||
|
||||
// 'ps ax' should be standard across all MacOS and Linux.
|
||||
// However, ps on OS X corrupts some non-ASCII characters in arguments,
|
||||
// such as т (CYRILLIC SMALL LETTER TE), leading to this function
|
||||
// failing to properly match pathnames with those characters. #3999
|
||||
//
|
||||
// pgrep appears to do a better job (and has output that is roughly
|
||||
// similar; it lacks a few fields that we don't care about). Plus,
|
||||
// it can do some of the grepping for us.
|
||||
//
|
||||
// However, 'pgrep' only started shipping with OS X 10.8 (and may be less
|
||||
// common on Linux too), so we check to see if it exists and fall back to
|
||||
// 'ps' if we can't find it.
|
||||
child_process.exec(
|
||||
'ps ax',
|
||||
'if type pgrep >/dev/null 2>&1; then ' +
|
||||
// -lf means to display and match against full argument lists.
|
||||
// pgrep exits 1 if no processes match the argument; we're OK
|
||||
// considering this as a success, but we don't want other errors
|
||||
// to be ignored. Note that this is sh not bash, so we can't use
|
||||
// [[.
|
||||
'pgrep -lf mongod; test "$?" -eq 0 -o "$?" -eq 1;' +
|
||||
'else ps ax; fi',
|
||||
// we don't want this to randomly fail just because you're running lots of
|
||||
// processes. 10MB should be more than ps ax will ever spit out; the default
|
||||
// is 200K, which at least one person hit (#2158).
|
||||
|
||||
@@ -19,3 +19,38 @@ selftest.define("mongo failover", ["slow"], function () {
|
||||
run.expectEnd();
|
||||
run.expectExit(0);
|
||||
});
|
||||
|
||||
var testMeteorMongo = function (appDir) {
|
||||
var s = new Sandbox();
|
||||
s.createApp(appDir, 'standard-app');
|
||||
s.cd(appDir);
|
||||
|
||||
var run = s.run();
|
||||
run.waitSecs(15);
|
||||
run.match(appDir);
|
||||
run.match('proxy');
|
||||
run.match('Started MongoDB');
|
||||
|
||||
var mongoRun = s.run('mongo');
|
||||
mongoRun.match('MongoDB shell');
|
||||
mongoRun.match('connecting to: 127.0.0.1');
|
||||
// Note: when mongo shell's input is not a tty, there is no prompt.
|
||||
mongoRun.write('db.version()\n');
|
||||
mongoRun.match(/2\.6\.\d+/);
|
||||
mongoRun.stop();
|
||||
};
|
||||
|
||||
selftest.define("meteor mongo", function () {
|
||||
testMeteorMongo('asdfzasdf');
|
||||
});
|
||||
|
||||
// Regression test for #3999. Note the Cyrillic character in the pathname.
|
||||
//
|
||||
// XXX This test fails on Windows for two different reasons:
|
||||
// - With the Unicode directory name, `meteor run` fails to start mongod
|
||||
// - If you change appDir to not have the Unicode character, the reads
|
||||
// from the mongo shell process seem to be randomly corrupted
|
||||
// https://github.com/meteor/windows-preview/issues/145
|
||||
selftest.define("meteor mongo in unicode dir", function () {
|
||||
testMeteorMongo('asdf\u0442asdf');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user