-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
36 lines (28 loc) · 887 Bytes
/
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
#include "zgw.h"
#include <muduo/base/Logging.h>
#include <muduo/net/EventLoop.h>
#include <muduo/base/Thread.h>
#include "SimpleIni.h"
int main(int argc, char* argv[])
{
LOG_INFO << "Master线程启动,TID: " << muduo::CurrentThread::tid();
CSimpleIniA ini;
ini.SetUnicode();
int ret = ini.LoadFile("./config.ini");
if( ret < 0 )
{
LOG_ERROR << "加载配置文件失败,程序退出";
return -1;
}
const char* str_port = ini.GetValue("frontend", "port", "1520");
assert( str_port != NULL );
uint16_t port = static_cast<uint16_t>(atoi(str_port));
muduo::net::EventLoop loop;
muduo::net::InetAddress listenAddr(port);
ZGWServer zgw_svr(&loop, listenAddr, ini);
zgw_svr.start();
// main线程进入事件循环
loop.loop();
zgw_svr.wait();
return 0;
}