22#include < drogon/drogon.h>
33#include < climits> // for PATH_MAX
44#include < iostream>
5+ #include " controllers/command_line_parser.h"
56#include " cortex-common/cortexpythoni.h"
67#include " utils/cortex_utils.h"
78#include " utils/dylib.h"
9+ #include " utils/archive_utils.h"
810
911#if defined(__APPLE__) && defined(__MACH__)
1012#include < libgen.h> // for dirname()
2022#endif
2123
2224int main (int argc, char * argv[]) {
25+ // Create logs/ folder and setup log to file
26+ std::filesystem::create_directory (cortex_utils::logs_folder);
27+ trantor::AsyncFileLogger asyncFileLogger;
28+ asyncFileLogger.setFileName (cortex_utils::logs_base_name);
29+ asyncFileLogger.startLogging ();
30+ trantor::Logger::setOutputFunction (
31+ [&](const char * msg, const uint64_t len) {
32+ asyncFileLogger.output (msg, len);
33+ },
34+ [&]() { asyncFileLogger.flush (); });
35+ asyncFileLogger.setFileSizeLimit (cortex_utils::log_file_size_limit);
36+
2337 // Check if this process is for python execution
2438 if (argc > 1 ) {
2539 if (strcmp (argv[1 ], " --run_python_file" ) == 0 ) {
@@ -41,11 +55,17 @@ int main(int argc, char* argv[]) {
4155 }
4256 }
4357
58+ if (argc > 1 ) {
59+ CommandLineParser clp;
60+ clp.SetupCommand (argc, argv);
61+ return 0 ;
62+ }
63+
4464 int thread_num = 1 ;
4565 std::string host = " 127.0.0.1" ;
4666 int port = 3928 ;
4767
48- // Number of cortex- cpp threads
68+ // Number of cortex. cpp threads
4969 if (argc > 1 ) {
5070 thread_num = std::atoi (argv[1 ]);
5171 }
@@ -64,9 +84,9 @@ int main(int argc, char* argv[]) {
6484 int drogon_thread_num = std::max (thread_num, logical_cores);
6585 // cortex_utils::nitro_logo();
6686#ifdef CORTEX_CPP_VERSION
67- LOG_INFO << " cortex- cpp version: " << CORTEX_CPP_VERSION;
87+ LOG_INFO << " cortex. cpp version: " << CORTEX_CPP_VERSION;
6888#else
69- LOG_INFO << " cortex- cpp version: undefined" ;
89+ LOG_INFO << " cortex. cpp version: undefined" ;
7090#endif
7191
7292 LOG_INFO << " Server started, listening at: " << host << " :" << port;
@@ -78,4 +98,4 @@ int main(int argc, char* argv[]) {
7898 drogon::app ().run ();
7999
80100 return 0 ;
81- }
101+ }
0 commit comments