From 0ecf45bf848fa3c38ec99a45de2f52d0615cf80d Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Thu, 11 Mar 2010 11:55:10 -0500 Subject: [PATCH] minor: helpful error message when unable to acquire dbpath lock in tools --- tools/tool.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/tool.cpp b/tools/tool.cpp index fc91f4a1195..1a7a6a3c389 100644 --- a/tools/tool.cpp +++ b/tools/tool.cpp @@ -47,7 +47,10 @@ namespace mongo { ; if ( localDBAllowed ) _options->add_options() - ("dbpath",po::value(), "directly access mongod data files in the given path, instead of connecting to a mongod instance - needs to lock the data directory, so cannot be used if a mongod is currently accessing the same path" ) + ("dbpath",po::value(), "directly access mongod data " + "files in the given path, instead of connecting to a mongod " + "instance - needs to lock the data directory, so cannot be " + "used if a mongod is currently accessing the same path" ) ("directoryperdb", "if dbpath specified, each db is in a separate directory" ) ; @@ -157,7 +160,17 @@ namespace mongo { _host = "DIRECT"; static string myDbpath = getParam( "dbpath" ); dbpath = myDbpath.c_str(); - acquirePathLock(); + try { + acquirePathLock(); + } + catch ( DBException& e ){ + cerr << endl << "If you are running a mongod on the same " + "path you should connect to that instead of direct data " + "file access" << endl << endl; + dbexit( EXIT_CLEAN ); + return -1; + } + theFileAllocator().start(); }