mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
--profile command line option SERVER-456
This commit is contained in:
parent
3b37c3fbd4
commit
7d65d20f5a
@ -37,7 +37,8 @@ namespace mongo {
|
||||
bool cpu; // --cpu show cpu time periodically
|
||||
|
||||
long long oplogSize; // --oplogSize
|
||||
|
||||
int defaultProfile; // --profile
|
||||
|
||||
enum {
|
||||
DefaultDBPort = 27017,
|
||||
ConfigServerPort = 27019,
|
||||
@ -46,7 +47,7 @@ namespace mongo {
|
||||
|
||||
CmdLine() :
|
||||
port(DefaultDBPort), quiet(false), notablescan(false), prealloc(true), smallfiles(false),
|
||||
quota(false), quotaFiles(8), cpu(false), oplogSize(0)
|
||||
quota(false), quotaFiles(8), cpu(false), oplogSize(0), defaultProfile(0)
|
||||
{ }
|
||||
|
||||
};
|
||||
|
@ -40,7 +40,8 @@ namespace mongo {
|
||||
|
||||
assert( cc().database() == this );
|
||||
|
||||
if ( ! nsdetails( profileName.c_str() ) ){
|
||||
if ( ! namespaceIndex.details( profileName.c_str() ) ){
|
||||
log(1) << "creating profile ns: " << profileName << endl;
|
||||
BSONObjBuilder spec;
|
||||
spec.appendBool( "capped", true );
|
||||
spec.append( "size", 131072.0 );
|
||||
@ -52,4 +53,12 @@ namespace mongo {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Database::finishInit(){
|
||||
if ( cmdLine.defaultProfile == profile )
|
||||
return;
|
||||
|
||||
string errmsg;
|
||||
massert( 12506 , errmsg , setProfilingLevel( cmdLine.defaultProfile , errmsg ) );
|
||||
}
|
||||
|
||||
} // namespace mongo
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cmdline.h"
|
||||
|
||||
/* Database represents a database database
|
||||
Each database database has its own set of files -- dbname.ns, dbname.0, dbname.1, ...
|
||||
*/
|
||||
@ -48,11 +50,13 @@ namespace mongo {
|
||||
|
||||
// If already exists, open. Otherwise behave as if empty until
|
||||
// there's a write, then open.
|
||||
if ( !newDb ) {
|
||||
if ( ! newDb || cmdLine.defaultProfile ) {
|
||||
namespaceIndex.init();
|
||||
if( _openAllFiles )
|
||||
openAllFiles();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
~Database() {
|
||||
@ -170,6 +174,8 @@ namespace mongo {
|
||||
*/
|
||||
bool setProfilingLevel( int newLevel , string& errmsg );
|
||||
|
||||
void finishInit();
|
||||
|
||||
vector<MongoDataFile*> files;
|
||||
string name; // "alleyinsider"
|
||||
string path;
|
||||
|
@ -584,6 +584,7 @@ int main(int argc, char* argv[], char *envp[] )
|
||||
("repair", "run repair on all dbs")
|
||||
("notablescan", "do not allow table scans")
|
||||
("syncdelay",po::value<double>(&dataFileSync._sleepsecs)->default_value(60), "seconds between disk syncs (0 for never)")
|
||||
("profile",po::value<int>(), "0=off 1=slow, 2=all")
|
||||
#if defined(_WIN32)
|
||||
("install", "install mongodb service")
|
||||
("remove", "remove mongodb service")
|
||||
@ -868,7 +869,8 @@ int main(int argc, char* argv[], char *envp[] )
|
||||
if ( params.count("configsvr" ) && params.count( "diaglog" ) == 0 ){
|
||||
_diaglog.level = 1;
|
||||
}
|
||||
|
||||
if ( params.count( "profile" ) )
|
||||
cmdLine.defaultProfile = params["profile"].as<int>();
|
||||
Module::configAll( params );
|
||||
dataFileSync.go();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user