core-legacy/main.cc

51 lines
922 B
C++
Raw Normal View History

2019-07-12 19:05:56 +00:00
#include <drogon/drogon.h>
#include <sqlite3.h>
#include <models/device_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 ) {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(globals::db));
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;
}