mirror of
https://github.com/Relintai/mourne_rcpp_fw.git
synced 2025-02-02 23:05:54 +01:00
Initialize platforms, and check whether to run migrations using the arg parser.
This commit is contained in:
parent
62d0d59cc9
commit
01dbdb6aa1
32
main.cpp
32
main.cpp
@ -21,10 +21,13 @@
|
|||||||
//Backends
|
//Backends
|
||||||
#include "backends/hash_hashlib/setup.h"
|
#include "backends/hash_hashlib/setup.h"
|
||||||
|
|
||||||
#include "modules/users/user.h"
|
|
||||||
#include "app/mourne_user_controller.h"
|
#include "app/mourne_user_controller.h"
|
||||||
|
#include "modules/users/user.h"
|
||||||
#include "modules/users/user_model.h"
|
#include "modules/users/user_model.h"
|
||||||
|
|
||||||
|
#include "core/os/platform.h"
|
||||||
|
#include "platform/platform_initializer.h"
|
||||||
|
|
||||||
#include "core/database/database_manager.h"
|
#include "core/database/database_manager.h"
|
||||||
|
|
||||||
void initialize_backends() {
|
void initialize_backends() {
|
||||||
@ -40,19 +43,12 @@ void create_databases() {
|
|||||||
db->connect("database.sqlite");
|
db->connect("database.sqlite");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv, char **envp) {
|
||||||
|
PlatformInitializer::allocate_all();
|
||||||
|
PlatformInitializer::arg_setup(argc, argv, envp);
|
||||||
|
|
||||||
initialize_backends();
|
initialize_backends();
|
||||||
|
|
||||||
bool migrate = false;
|
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
|
||||||
const char *a = argv[i];
|
|
||||||
|
|
||||||
if (a[0] == 'm') {
|
|
||||||
migrate = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::SessionManager *session_manager = new ::SessionManager();
|
::SessionManager *session_manager = new ::SessionManager();
|
||||||
|
|
||||||
//todo init these in the module automatically
|
//todo init these in the module automatically
|
||||||
@ -73,17 +69,19 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
DWebApplication *app = new MAIN_CLASS();
|
DWebApplication *app = new MAIN_CLASS();
|
||||||
|
|
||||||
session_manager->load_sessions();
|
|
||||||
|
|
||||||
app->load_settings();
|
app->load_settings();
|
||||||
app->setup_routes();
|
app->setup_routes();
|
||||||
app->setup_middleware();
|
app->setup_middleware();
|
||||||
|
|
||||||
app->add_listener("127.0.0.1", 8080);
|
bool migrate = Platform::get_singleton()->arg_parser.has_arg("m");
|
||||||
LOG_INFO << "Server running on 127.0.0.1:8080";
|
|
||||||
|
|
||||||
if (!migrate) {
|
if (!migrate) {
|
||||||
printf("Initialized!\n");
|
printf("Initialized!\n");
|
||||||
|
session_manager->load_sessions();
|
||||||
|
|
||||||
|
app->add_listener("127.0.0.1", 8080);
|
||||||
|
LOG_INFO << "Server running on 127.0.0.1:8080";
|
||||||
|
|
||||||
app->run();
|
app->run();
|
||||||
} else {
|
} else {
|
||||||
printf("Running migrations.\n");
|
printf("Running migrations.\n");
|
||||||
@ -102,5 +100,7 @@ int main(int argc, char **argv) {
|
|||||||
delete user_model;
|
delete user_model;
|
||||||
delete session_manager;
|
delete session_manager;
|
||||||
|
|
||||||
|
PlatformInitializer::free_all();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user