core-legacy/main.cc
2019-08-22 21:38:23 +02:00

54 lines
1,008 B
C++

#include <drogon/drogon.h>
#include <sqlite3.h>
#include <models/controller_dbo.h>
#include <csignal>
#include "globals.h"
#include "config.h"
static void
terminate(int signum)
{
LOG_INFO << "Terminating Server (" << signum << ")";
sqlite3_close(globals::db);
quick_exit(signum);
}
/*static void test()
{
LOG_DEBUG << "LOOP";
}*/
int
main()
{
signal(SIGINT, terminate);
signal(SIGABRT, terminate);
signal(SIGTERM, terminate);
signal(SIGKILL, terminate);
int rc;
/* Open database */
rc = sqlite3_open("test.db", &globals::db);
if( rc ) {
LOG_FATAL << "Can't open database: " << sqlite3_errmsg(globals::db);
return 1;
}
//Load config file
drogon::app().loadConfigFile("config.json");
//drogon::app().getLoop()->runEvery(1, &test);
//Run HTTP framework,the method will block in the internal event loop
LOG_INFO << "Starting Emgauwa Core (" << config::version << ")";
drogon::app().run();
return 0;
}