#include #include #include "nexusserver.h" bool restart_when_fatal = true; void restart(){ // TODO: Launch Another Instance in a new Process } void shutdown(int sig){ // Shutdown Gracefully printf("Received Signal: %i\n", sig); QCoreApplication::quit(); } void fatal(int sig){ qCritical() << "Fatal Error Occured... Server is Terminating..."; // Due to possible data corruption // It is not safe to try and salvage any active memory // So just exit here... // TODO: Run Bug Collector and Report data to Development Site if(restart_when_fatal) restart(); exit(sig); } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); signal(SIGINT, shutdown); // CTRL+C Signal #if !defined(Q_OS_UNIX) signal(SIGBREAK, shutdown); // Console Destroyed Signal for Windows #else signal(SIGQUIT, shutdown); // Quit Signal signal(SIGHUP, shutdown); // Hangup Signal #endif signal(SIGTERM, shutdown); // Terminate Signal, Impatience signal(SIGILL, fatal); // Illegal Instruction signal(SIGSEGV, fatal); // Segmentation Fault signal(SIGABRT, fatal); // Abort Request signal(SIGFPE, fatal); // Floating Point Error NexusServer server; return a.exec(); }