-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.h
More file actions
76 lines (63 loc) · 1.72 KB
/
Copy pathServer.h
File metadata and controls
76 lines (63 loc) · 1.72 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
#pragma once
#include <iostream>
#include <unordered_map>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/epoll.h>
#include <signal.h>
#include <sys/wait.h>
#include <hiredis/hiredis.h>
#include <libconfig.h++>
#include <time.h>
#include "ThreadPool.h"
#include "http/Handler.h"
#include "http/HttpResponse.h"
#include "Log.h"
using namespace libconfig;
using namespace std;
class Handler;
class Server{
public:
//用来初始化服务器的函数
static void loadConfig(string path); //守护进程化前的初始化
static void init(); //守护进程化后的初始化
static void start();
static void free();
//用来获得信息的函数
static string getRedisIp(){ return redis_ip; }
static int getRedisPort(){ return redis_port; }
static int getEpollFd(){ return epoll_fd; }
static string getRoot(){ return root; }
private:
//错误相关
static void showError(int connfd, Status st);
static unordered_map<Status, HttpResponse> error_map;
//限制参数
static int thread_num;
static int queue_size;
static int max_fd;
//连接参数
static int port;
static string root;
static int listen_fd;
//redis参数
static string redis_ip;
static int redis_port;
//功能模块
static Handler* handler;
static ThreadPool thread_pool;
static int epoll_fd;
static struct epoll_event *ep_events;
static bool stop;
/*Log模块相关参数*/
static string log_path;
static bool info_on;
static bool debug_on;
static bool warn_on;
static bool error_on;
};