0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 09:06:21 +01:00

SERVER-425 Configurable path for pid/lock file

Signed-off-by: Eliot Horowitz <eliot@10gen.com>
This commit is contained in:
Guillaume Delannoy 2010-03-31 16:39:43 -04:00 committed by Eliot Horowitz
parent 8657d88065
commit 1f655abccb
4 changed files with 8 additions and 3 deletions

View File

@ -616,6 +616,9 @@ int main(int argc, char* argv[], char *envp[] )
("bind_ip", po::value<string>(&bind_ip),
"local ip address to bind listener - all local ips bound by default")
("dbpath", po::value<string>()->default_value("/data/db/"), "directory for datafiles")
#if !defined(_WIN32) && !defined(__sunos__)
("lockfilepath", po::value<string>(&lockfilepath), "directory for lockfile (if not set, dbpath is used)")
#endif
("directoryperdb", "each database will be stored in a separate directory")
("repairpath", po::value<string>() , "root directory for repair files - defaults to dbpath" )
("cpu", "periodically show cpu and iowait utilization")

View File

@ -706,7 +706,7 @@ namespace mongo {
void acquirePathLock() {
#if !defined(_WIN32) && !defined(__sunos__)
string name = ( boost::filesystem::path( dbpath ) / "mongod.lock" ).native_file_string();
string name = ( boost::filesystem::path( lockfilepath.empty() ? dbpath : lockfilepath ) / "mongod.lock" ).native_file_string();
bool oldFile = false;
@ -715,8 +715,8 @@ namespace mongo {
}
lockFile = open( name.c_str(), O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO );
uassert( 10309 , "Unable to create / open lock file for dbpath: " + name, lockFile > 0 );
uassert( 10310 , "Unable to acquire lock for dbpath: " + name, flock( lockFile, LOCK_EX | LOCK_NB ) == 0 );
uassert( 10309 , "Unable to create / open lock file for lockfilepath: " + name, lockFile > 0 );
uassert( 10310 , "Unable to acquire lock for lockfilepath: " + name, flock( lockFile, LOCK_EX | LOCK_NB ) == 0 );
if ( oldFile ){
// we check this here because we want to see if we can get the lock

View File

@ -674,6 +674,7 @@ namespace mongo {
extern string dbpath; // --dbpath parm
extern bool directoryperdb;
extern string lockfilepath; // --lockfilepath param
// Rename a namespace within current 'client' db.
// (Arguments should include db name)

View File

@ -98,6 +98,7 @@ namespace mongo {
string dbpath = "/data/db/";
bool directoryperdb = false;
string repairpath;
string lockfilepath;
DataFileMgr theDataFileMgr;
DatabaseHolder dbHolder;