-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMain.cpp
48 lines (44 loc) · 1.24 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
/*************************************************************************
> File Name: Main.cpp
> Author: zhangfeng
> Mail: [email protected]
> Created Time: Mon 07 Oct 2019 07:24:40 PM CST
> Target:
************************************************************************/
#include "EventLoop.h"
#include "Server.h"
#include "base/Logging.h"
#include <getopt.h>
#include <string>
#include <stdio.h>
int main(int argc, char *argv[]) {
int threadNum = 4;
int port = 80;
std::string logPath = "./WebServer.log";
int opt;
const char *str = "t:l:p:";
while((opt = getopt(argc, argv, str)) != -1) {
switch(opt) {
case 't':{
threadNum = atoi(optarg);
break;
}
case 'l':{
logPath = optarg;
break;
}
case 'p': {
port = atoi(optarg);
break;
}
default:break;
}
}
Logger::setLogFileName(logPath);
std::cout << "threadNum: " << threadNum << ", port: " << port << ", logPath: " << logPath << endl;
EventLoop mainLoop;
Server myHTTPServer(&mainLoop, threadNum, port);
myHTTPServer.start();
mainLoop.loop();
return 0;
}