-/* signal.c - NeonServ v5.5
+/* signal.c - NeonServ v5.6
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
#include "ClientSocket.h"
#include "IOHandler.h"
#include "ConfigParser.h"
+#include "log.h"
static void sigcrash();
static void sigexit();
void sighandler(int signum) {
- putlog(LOGLEVEL_INFO, "Received Signal %d\n", signum);
+ printf_log("main", LOG_INFO, "Received Signal %d\n", signum);
signal(signum, SIG_DFL);
switch(signum) {
case SIGABRT:
signame = "SIGUNKNOWN";
break;
}
- putlog(LOGLEVEL_ERROR, "NeonServ process crashed (%s)\n", signame);
+ printf_log("main", LOG_ERROR, "NeonServ process crashed (%s)\n", signame);
#ifndef WIN32
char gcore[50];
sprintf(gcore, "gcore %u", getpid());
int sysretn = system(gcore); //generate core file
sprintf(coregen, "core file generated. (%d)", sysretn);
- putlog(LOGLEVEL_ERROR | LOGLEVEL_INFO, "generated core file.\n");
+ printf_log("main", LOG_ERROR | LOG_INFO, "generated core file.\n");
#endif
- char *alertchan = get_string_field("General.alertchan");
- if(alertchan) {
- struct ChanNode *channel = getChanByName(alertchan);
- struct ClientSocket *client;
- if(channel && (client = getChannelBot(channel, 0))) {
- putsock(client, "PRIVMSG %s :\00304NeonServ received signal %d (%s). %s", alertchan, signum, signame, coregen);
- }
- }
//close all bots
struct ClientSocket *bot;
for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
bot->iofd = NULL;
}
}
- putlog(LOGLEVEL_INFO, "hard shutdown...\n");
- exit_daemon();
+ printf_log("main", LOG_INFO, "hard shutdown...\n");
usleep(2000000);
//hard restart
- restart_process();
+ restart_bot(1);
exit(0);
}
static void sigexit(int signum) {
- cleanup();
- exit_daemon();
- exit(0);
+ stop_bot();
}