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

move shutdown to generic so can be used by mongos

This commit is contained in:
Eliot Horowitz 2010-07-26 21:48:20 -04:00
parent 7740fb4070
commit 9007388324
2 changed files with 27 additions and 25 deletions

View File

@ -46,31 +46,6 @@ namespace mongo {
extern int otherTraceLevel;
void flushOpLog( stringstream &ss );
class CmdShutdown : public Command {
public:
virtual bool requiresAuth() { return true; }
virtual bool adminOnly() const { return true; }
virtual bool localHostOnlyIfNoAuth(const BSONObj& cmdObj) { return true; }
virtual bool logTheOp() {
return false;
}
virtual bool slaveOk() const {
return true;
}
virtual LockType locktype() const { return NONE; }
virtual void help( stringstream& help ) const {
help << "shutdown the database. must be ran against admin db and either (1) ran from localhost or (2) authenticated.\n";
}
CmdShutdown() : Command("shutdown") {}
bool run(const string& dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
dblock l;
cc().shutdown();
log() << "terminating, shutdown command received" << endl;
dbexit( EXIT_CLEAN ); // this never returns
return true;
}
} cmdShutdown;
/* reset any errors so that getlasterror comes back clean.
useful before performing a long series of operations where we want to

View File

@ -190,5 +190,32 @@ namespace mongo {
}
} listCommandsCmd;
class CmdShutdown : public Command {
public:
virtual bool requiresAuth() { return true; }
virtual bool adminOnly() const { return true; }
virtual bool localHostOnlyIfNoAuth(const BSONObj& cmdObj) { return true; }
virtual bool logTheOp() {
return false;
}
virtual bool slaveOk() const {
return true;
}
virtual LockType locktype() const { return WRITE; }
virtual void help( stringstream& help ) const {
help << "shutdown the database. must be ran against admin db and either (1) ran from localhost or (2) authenticated.\n";
}
CmdShutdown() : Command("shutdown") {}
bool run(const string& dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
Client * c = currentClient.get();
if ( c )
c->shutdown();
log() << "terminating, shutdown command received" << endl;
dbexit( EXIT_CLEAN ); // this never returns
return true;
}
} cmdShutdown;
}