usleep(100000); // Sleep for 10ms to attempt to allow the previous Broadcast() to go through to all users
throw CException(CException::EX_Shutdown);
+ } else if (m_pUser->IsAdmin() && sCommand.CaseCmp("RESTART") == 0) {
+ CString sMessage = sLine.Token(1, true);
+
+ if (sMessage.empty()) {
+ sMessage = "ZNC is being restarted NOW!!";
+ }
+
+ CZNC::Get().Broadcast(sMessage);
+ throw CException(CException::EX_Restart);
} else if (sCommand.CaseCmp("JUMP") == 0 ||
sCommand.CaseCmp("CONNECT") == 0) {
if (m_pUser) {
Table.SetCell("Command", "Shutdown");
Table.SetCell("Arguments", "[message]");
Table.SetCell("Description", "Shutdown znc completely");
+
+ Table.AddRow();
+ Table.SetCell("Command", "Restart");
+ Table.SetCell("Arguments", "[message]");
+ Table.SetCell("Description", "Restarts znc");
}
if (Table.size()) {
try {
iRet = pZNC->Loop();
} catch (CException e) {
- // EX_Shutdown is thrown to exit
switch (e.GetType()) {
case CException::EX_Shutdown:
iRet = 0;
+ break;
+ case CException::EX_Restart: {
+ // strdup() because GCC is stupid
+ char *args[] = {
+ strdup(argv[0]),
+ strdup("--datadir"),
+ strdup(pZNC->GetZNCPath().c_str()),
+ strdup(pZNC->GetConfigFile().c_str()),
+ NULL
+ };
+ execvp(args[0], args);
+ CUtils::PrintError("Unable to restart znc [" + CString(strerror(errno)) + "]");
+ } /* Fall through */
default:
iRet = 1;
}