-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
75 lines (72 loc) · 1.71 KB
/
main.cpp
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "Logger.h"
#include "XMarketCenter.h"
#include <stdio.h>
void printHelp()
{
printf("Usage: XMarketCenter -d -f ~/config.yml\n");
printf("\t-f: Config File Path\n");
printf("\t-a: Account\n");
printf("\t-L: Plugin So path\n");
printf("\t-d: log debug mode, print debug log\n");
printf("\t-h: print help information\n");
}
int main(int argc, char *argv[])
{
std::string configPath = "./config.yml";
std::string Account;
int ch;
std::string soPath;
bool check = false;
bool debug = false;
while ((ch = getopt(argc, argv, "f:a:L:dh")) != -1)
{
switch (ch)
{
case 'f':
configPath = optarg;
break;
case 'a':
Account = optarg;
break;
case 'L':
soPath = optarg;
break;
case 'd':
debug = true;
break;
case 'h':
case '?':
case ':':
default:
printHelp();
exit(-1);
break;
}
}
std::string app_log_path;
char* p = getenv("APP_LOG_PATH");
if(p == NULL)
{
app_log_path = "./log/";
}
else
{
app_log_path = p;
}
Utils::gLogger = Utils::Singleton<Utils::Logger>::GetInstance();
Utils::gLogger->setLogPath(app_log_path, "XMarketCenter");
Utils::gLogger->Init();
Utils::gLogger->setDebugLevel(debug);
std::string cmd;
for(int i = 0; i < argc; i++)
{
cmd += (std::string(argv[i]) + " ");
}
// start Market Center
XMarketCenter engine;
engine.LoadConfig(configPath.c_str());
engine.SetCommand(cmd);
engine.LoadMarketGateWay(soPath);
engine.Run();
return 0;
}