summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/anoperc.in3
-rw-r--r--src/config.cpp1
-rw-r--r--src/main.cpp107
3 files changed, 35 insertions, 76 deletions
diff --git a/src/bin/anoperc.in b/src/bin/anoperc.in
index f50174042..94cdd6316 100644
--- a/src/bin/anoperc.in
+++ b/src/bin/anoperc.in
@@ -93,7 +93,6 @@ elif [ "$1" = "status" ] ; then
echo "Anope is not currently running"
-## :/ SIGUSR2 is ignored after the first restart so we stop / start Anope for now ##
elif [ "$1" = "restart" ] ; then
isAnopeRunning
echo "Restarting Anope"
@@ -105,7 +104,7 @@ elif [ "$1" = "restart" ] ; then
elif [ "$1" = "rehash" ] ; then
isAnopeRunning
echo "Saving Databases and Rehashing Configuration"
- kill -12 `cat $ANOPEPID`
+ kill -1 `cat $ANOPEPID`
elif [ "$1" = "version" ] ; then
$ANOPROG -version
diff --git a/src/config.cpp b/src/config.cpp
index 612aecf66..d43f97e6f 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -1009,7 +1009,6 @@ void ServerConfig::Read()
{"options", "forceforbidreason", "no", new ValueContainerBool(&this->ForceForbidReason), DT_BOOLEAN, NoValidation},
{"options", "useprivmsg", "no", new ValueContainerBool(&this->UsePrivmsg), DT_BOOLEAN, NoValidation},
{"options", "usestrictprivmsg", "no", new ValueContainerBool(&this->UseStrictPrivMsg), DT_BOOLEAN, NoValidation},
- {"options", "dumpcore", "yes", new ValueContainerBool(&this->DumpCore), DT_BOOLEAN | DT_NORELOAD, NoValidation},
{"options", "hidestatso", "no", new ValueContainerBool(&this->HideStatsO), DT_BOOLEAN, NoValidation},
{"options", "globaloncycle", "no", new ValueContainerBool(&this->GlobalOnCycle), DT_BOOLEAN, NoValidation},
{"options", "globaloncycledown", "", new ValueContainerString(&this->GlobalOnCycleMessage), DT_STRING, ValidateGlobalOnCycle},
diff --git a/src/main.cpp b/src/main.cpp
index 64e755b7c..04baf1dd3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -248,81 +248,55 @@ void sighandler(int signum)
* QUIT code without having a valid quitmsg. -GD
*/
if (quitmsg.empty())
- quitmsg = "Services terminating via a signal.";
+ quitmsg = Anope::string("Services terminating via signal ") + strsignal(signum) + " (" + stringify(signum) + ")";
+ bool fatal = false;
if (started)
{
-#ifndef _WIN32
- if (signum == SIGHUP)
+ switch (signum)
{
- Log() << "Received SIGHUP: Saving Databases & Rehash Configuration";
-
- expire_all();
- save_databases();
+#ifndef _WIN32
+ case SIGHUP:
+ Log() << "Received SIGHUP: Saving Databases & Rehash Configuration";
- try
- {
- ServerConfig *newconfig = new ServerConfig();
- delete Config;
- Config = newconfig;
- FOREACH_MOD(I_OnReload, OnReload(true));
- }
- catch (const ConfigException &ex)
- {
- Log() << "Error reloading configuration file: " << ex.GetReason();
- }
- return;
+ expire_all();
+ save_databases();
- }
- else
+ try
+ {
+ ServerConfig *newconfig = new ServerConfig();
+ delete Config;
+ Config = newconfig;
+ FOREACH_MOD(I_OnReload, OnReload(true));
+ }
+ catch (const ConfigException &ex)
+ {
+ Log() << "Error reloading configuration file: " << ex.GetReason();
+ }
+ break;
#endif
- if (signum == SIGTERM)
- {
- signal(SIGTERM, SIG_IGN);
+ case SIGINT:
+ case SIGTERM:
+ signal(signum, SIG_IGN);
#ifndef _WIN32
- signal(SIGHUP, SIG_IGN);
+ signal(SIGHUP, SIG_IGN);
#endif
- Log() << "Received SIGTERM, exiting.";
+ Log() << "Received " << strsignal(signum) << " signal (" << signum << "), exiting.";
- expire_all();
- save_databases();
- quitmsg = "Shutting down on SIGTERM";
- services_shutdown();
- exit(0);
- }
- else if (signum == SIGINT)
- {
- if (nofork)
- {
- signal(SIGINT, SIG_IGN);
- Log() << "Received SIGINT, exiting.";
expire_all();
save_databases();
- quitmsg = "Shutting down on SIGINT";
- services_shutdown();
- exit(0);
- }
+ quitmsg = "shutting down on sigterm";
+ default:
+ fatal = true;
+ break;
}
}
- /* Should we send the signum here as well? -GD */
- FOREACH_MOD(I_OnSignal, OnSignal(quitmsg));
-
- if (started)
- {
- services_shutdown();
- exit(0);
- }
- else
- {
- if (isatty(2))
- fprintf(stderr, "%s\n", quitmsg.c_str());
- else
- Log() << quitmsg;
+ FOREACH_MOD(I_OnSignal, OnSignal(signum, quitmsg));
- exit(1);
- }
+ if (fatal)
+ throw FatalException(quitmsg);
}
/*************************************************************************/
@@ -465,21 +439,6 @@ int main(int ac, char **av, char **envp)
started = true;
-#ifndef _WIN32
- if (Config->DumpCore)
- {
- rlimit rl;
- if (getrlimit(RLIMIT_CORE, &rl) == -1)
- Log() << "Failed to getrlimit()!";
- else
- {
- rl.rlim_cur = rl.rlim_max;
- if (setrlimit(RLIMIT_CORE, &rl) == -1)
- Log() << "setrlimit() failed, cannot increase coredump size";
- }
- }
-#endif
-
/* Set up timers */
time_t last_check = time(NULL);
ExpireTimer expireTimer(Config->ExpireTimeout, last_check);
@@ -570,6 +529,8 @@ int main(int ac, char **av, char **envp)
{
if (!ex.GetReason().empty())
Log(LOG_TERMINAL) << ex.GetReason();
+ if (started)
+ services_shutdown();
return -1;
}