-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
62 lines (44 loc) · 1.22 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
49
50
51
52
53
54
55
56
57
58
59
60
///
/// @file main.cc
/// @author sgzed([email protected])
/// @date 2018-03-26 19:36:08
///
#include "SpellcorretServer.h"
#include "MyConf.h"
#include "IndexProducer.h"
#include "DictProducer.h"
#include <muduo/base/Logging.h>
#include <muduo/net/EventLoop.h>
#include <sstream>
#include <stdlib.h>
#include <unistd.h>
//#include "Configuration.h"
uint16_t str2unshort(string& str)
{
std::istringstream iss(str);
uint16_t unshort;
iss >> unshort ;
return unshort;
}
int main()
{
// Configuration f("./conf/my.conf");
MyConf::getInstance()->show();
std::map<string,string> confMap = MyConf::getInstance()->getConfigMap();
string ip = confMap["my_ip"];
string port = confMap["my_port"];
string store = confMap["my_dict"];
string numThreads = confMap["my_thread_num"];
// DictProducer dict("./english.txt");
// dict.build_dict();
// dict.store_dict(store.c_str());
IndexProducer::getInstance()->show();
LOG_INFO << "pid = " << getpid();
muduo::net::EventLoop loop;
LOG_INFO << "ip = " << ip << " port = " << str2unshort(port);
muduo::net::InetAddress listenAddr(ip,str2unshort(port));
SpellCorrectServer server(&loop,listenAddr,str2unshort(numThreads));
server.start();
loop.loop();
return 0;
}