inspircd/src/cmd_restart.cpp
brain 1bfe43ebfd Add more comments.
Catch CoreException in cmd_restart, and if we catch one, just exit(0). Theres very little else we could do.


git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6070 e03df62e-2008-0410-955e-edbf42e46eb7
2006-12-23 14:54:47 +00:00

51 lines
1.3 KiB
C++

/* +------------------------------------+
* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
* InspIRCd: (C) 2002-2007 InspIRCd Development Team
* See: http://www.inspircd.org/wiki/index.php/Credits
*
* This program is free but copyrighted software; see
* the file COPYING for details.
*
* ---------------------------------------------------
*/
#include "configreader.h"
#include "users.h"
#include "commands/cmd_restart.h"
extern "C" command_t* init_command(InspIRCd* Instance)
{
return new cmd_restart(Instance);
}
CmdResult cmd_restart::Handle (const char** parameters, int pcnt, userrec *user)
{
ServerInstance->Log(DEFAULT,"Restart: %s",user->nick);
if (!strcmp(parameters[0],ServerInstance->Config->restartpass))
{
ServerInstance->WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host);
try
{
ServerInstance->Restart("Server restarting.");
}
catch (CoreException &e)
{
/* We dont actually get here unless theres some fatal and unrecoverable error. */
exit(0);
}
}
else
{
ServerInstance->WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
return CMD_FAILURE;
}
return CMD_SUCCESS;
}