-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathmain.cc
48 lines (40 loc) · 1.15 KB
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "utils/nitro_utils.h"
#include <climits> // for PATH_MAX
#include <drogon/HttpAppFramework.h>
#include <drogon/drogon.h>
#if defined(__APPLE__) && defined(__MACH__)
#include <libgen.h> // for dirname()
#include <mach-o/dyld.h>
#elif defined(__linux__)
#include <libgen.h> // for dirname()
#include <unistd.h> // for readlink()
#elif defined(_WIN32)
#include <windows.h>
#else
#error "Unsupported platform!"
#endif
int main(int argc, char *argv[]) {
int thread_num = std::thread::hardware_concurrency();
std::string host = "127.0.0.1";
int port = 3928;
// Number of nitro threads
if (argc > 1) {
thread_num = std::atoi(argv[1]);
}
// Check for host argument
if (argc > 2) {
host = argv[2];
}
// Check for port argument
if (argc > 3) {
port = std::atoi(argv[3]); // Convert string argument to int
}
nitro_utils::nitro_logo();
LOG_INFO << "Server started, listening at: " << host << ":" << port;
LOG_INFO << "Please load your model";
drogon::app().addListener(host, port);
drogon::app().setThreadNum(thread_num);
LOG_INFO << "Number of thread is:" << drogon::app().getThreadNum();
drogon::app().run();
return 0;
}