forked from awwit/httpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.h
More file actions
86 lines (65 loc) · 1.86 KB
/
Server.h
File metadata and controls
86 lines (65 loc) · 1.86 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
#pragma once
#include "../socket/Adapter.h"
#include "../system/Module.h"
#include "ServerControls.h"
#include "ServerSettings.h"
#include "SocketsQueue.h"
#include <gnutls/gnutls.h>
namespace HttpServer
{
class Server
{
protected:
ServerSettings settings;
std::unordered_map<int, std::tuple<gnutls_certificate_credentials_t, gnutls_priority_t> > tls_data;
// std::unordered_map<SocketAdapter *, std::queue<std::tuple<uint32_t> > > http_streams;
std::vector<System::Module> modules;
std::vector<Socket::Socket> liseners;
mutable std::atomic_size_t threads_working_count;
System::CachePadding<std::atomic_size_t> padding_1;
public:
mutable ServerControls controls;
protected:
int cycleQueue(SocketsQueue &sockets);
void threadRequestProc(
Socket::Adapter &sock,
SocketsQueue &sockets,
Http2::IncStream *stream
) const;
void threadRequestCycle(
SocketsQueue &sockets,
Utils::Event &eventThreadCycle
) const;
bool tryBindPort(
const int port,
std::unordered_set<int> &ports
);
void initAppsPorts();
bool init();
int run();
void clear();
static System::native_processid_type getServerProcessId(const std::string &serverName);
void updateModules();
bool updateModule(
System::Module &module,
std::unordered_set<ServerApplicationSettings *> &applications,
const size_t moduleIndex
);
private:
static bool get_start_args(
const int argc,
const char *argv[],
struct server_start_args *st
);
public:
Server() = default;
void stop();
void restart();
void update();
int command_help(const int argc, const char *argv[]) const;
int command_start(const int argc, const char *argv[]);
int command_restart(const int argc, const char *argv[]) const;
int command_terminate(const int argc, const char *argv[]) const;
int command_update_module(const int argc, const char *argv[]) const;
};
}