rcpp_framework/main.cpp

63 lines
1.1 KiB
C++
Raw Normal View History

2020-11-24 15:41:18 +01:00
#include <iostream>
2020-11-25 00:20:41 +01:00
#include <string>
#include <string.h>
2020-11-24 15:41:18 +01:00
2020-11-25 13:28:34 +01:00
#include "core/application.h"
#include "core/file_cache.h"
#include "core/http_server.h"
2020-11-24 15:41:18 +01:00
2020-11-25 00:20:41 +01:00
#include "rdn_application.h"
2020-11-24 15:41:18 +01:00
#include "core/database_manager.h"
#include "database/db_init.h"
2020-11-25 00:20:41 +01:00
#define MAIN_CLASS RDNApplication
2020-11-24 15:41:18 +01:00
2020-11-25 00:20:41 +01:00
int main(int argc, char **argv) {
bool migrate = false;
for (int i = 1; i < argc; ++i) {
const char *a = argv[i];
if (a[0] == 'm') {
migrate = true;
}
}
initialize_database_backends();
FileCache *file_cache = new FileCache(true);
file_cache->wwwroot = "./www";
file_cache->wwwroot_refresh_cache();
DatabaseManager *dbm = new DatabaseManager();
uint32_t index = dbm->create_database("mysql");
Database *db = dbm->databases[0];
//db->_builder_creation_func = MysqlQueryBuilder::create;
db->connect("");
Application *app = new MAIN_CLASS();
2020-11-24 15:41:18 +01:00
app->setup_routes();
app->setup_middleware();
2020-11-24 15:41:18 +01:00
2020-11-25 00:20:41 +01:00
HTTPServer *server = new HTTPServer();
2020-11-24 15:41:18 +01:00
2020-11-25 00:20:41 +01:00
server->port = 8080;
server->initialize();
if (!migrate) {
server->main_loop();
} else {
app->migrate();
}
2020-11-24 15:41:18 +01:00
2020-11-25 00:20:41 +01:00
delete server;
delete app;
delete dbm;
delete file_cache;
2020-11-24 15:41:18 +01:00
2020-11-25 00:20:41 +01:00
return 0;
}