core-legacy/main.cc

51 lines
920 B
C++
Raw Normal View History

2019-07-12 19:05:56 +00:00
#include <drogon/drogon.h>
#include <sqlite3.h>
2019-07-22 20:06:13 +00:00
#include <models/controller_dbo.h>
2019-07-19 09:41:39 +00:00
#include <csignal>
2019-07-12 19:05:56 +00:00
#include "globals.h"
2019-07-19 12:42:36 +00:00
static void
terminate(int signum)
{
LOG_INFO << "Terminating Server (" << signum << ")";
sqlite3_close(globals::db);
quick_exit(signum);
}
2019-07-19 09:41:39 +00:00
/*static void test()
{
LOG_DEBUG << "LOOP";
}*/
2019-07-12 19:05:56 +00:00
2019-07-19 12:42:36 +00:00
int
main()
2019-07-19 09:41:39 +00:00
{
2019-07-19 12:42:36 +00:00
signal(SIGINT, terminate);
signal(SIGABRT, terminate);
signal(SIGTERM, terminate);
signal(SIGKILL, terminate);
2019-07-12 19:05:56 +00:00
int rc;
/* Open database */
rc = sqlite3_open("test.db", &globals::db);
if( rc ) {
2019-08-06 22:11:48 +00:00
LOG_FATAL << "Can't open database: " << sqlite3_errmsg(globals::db);
2019-07-12 19:05:56 +00:00
return 1;
}
//Load config file
drogon::app().loadConfigFile("../config.json");
2019-07-19 09:41:39 +00:00
//drogon::app().getLoop()->runEvery(1, &test);
2019-07-12 19:05:56 +00:00
//Run HTTP framework,the method will block in the internal event loop
drogon::app().run();
return 0;
}