-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderServer.cpp
More file actions
90 lines (78 loc) · 2.04 KB
/
OrderServer.cpp
File metadata and controls
90 lines (78 loc) · 2.04 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "OrderServer.h"
#include "OrderServantImp.h"
#include "curl/curl.h"
#include "LogComm.h"
//
using namespace std;
//
OrderServer g_app;
/////////////////////////////////////////////////////////////////
void
OrderServer::initialize()
{
//initialize application here:
//...
addServant<OrderServantImp>(ServerConfig::Application + "." + ServerConfig::ServerName + ".OrderServantObj");
//初始化外部接口对象
initOuterFactory();
// 注册动态加载命令
TARS_ADD_ADMIN_CMD_NORMAL("reload", OrderServer::reloadSvrConfig);
}
/*
* 配置变更,重新加载配置
*/
bool OrderServer::reloadSvrConfig(const string &command, const string ¶ms, string &result)
{
try
{
getOuterFactoryPtr()->load();
result = "reload server config success.";
LOG_DEBUG << "reloadSvrConfig: " << result << endl;
return true;
}
catch (TC_Exception const &e)
{
result = string("catch tc exception: ") + e.what();
}
catch (std::exception const &e)
{
result = string("catch std exception: ") + e.what();
}
catch (...)
{
result = "catch unknown exception.";
}
result += "\n fail, please check it.";
LOG_DEBUG << "reloadSvrConfig: " << result << endl;
return true;
}
/////////////////////////////////////////////////////////////////
void OrderServer::destroyApp()
{
//destroy application here:
//...
}
int OrderServer::initOuterFactory()
{
_pOuter = new OuterFactoryImp();
return 0;
}
/////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
try
{
g_app.main(argc, argv);
g_app.waitForShutdown();
}
catch (std::exception &e)
{
cerr << "std::exception:" << e.what() << std::endl;
}
catch (...)
{
cerr << "unknown exception." << std::endl;
}
return -1;
}
/////////////////////////////////////////////////////////////////