Webserv
Loading...
Searching...
No Matches
Server.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "http/MimeTypes.hpp"
5#include "http/Router.hpp"
8#include <signal.h>
9#include <vector>
10
11namespace core {
12
32class Server {
33public:
34 explicit Server(config::ServerConfig const &);
35 ~Server();
36
37 void start();
38 void stop();
39 bool getisRunning() const;
40 void requestShutDown();
41
42public:
49 static int getNullFd();
50
51private:
52 // clang-format off
54 volatile sig_atomic_t shutdownRequested_;
55 std::vector<network::Acceptor *> acceptors_;
56
61
62 int nullFd_;
63 // clang-format on
64
65 void setupAcceptors();
66 void cleanup();
67 void gracefulShutdown();
68
69 Server(const Server &);
71};
72
73} // namespace core
A strongly-typed data container for a server block's configuration.
Definition ServerConfig.hpp:22
bool getisRunning() const
Definition Server.cpp:109
Server & operator=(const Server &)
config::ServerConfig const & config_
Const reference to the parsed server configuration.
Definition Server.hpp:57
http::Router router_
HTTP request router for dispatching requests to handlers.
Definition Server.hpp:60
Server(const Server &)
static int getNullFd()
Gets the server-wide file descriptor for /dev/null.
Definition Server.cpp:140
std::vector< network::Acceptor * > acceptors_
Collection of active acceptor handlers (listening sockets).
Definition Server.hpp:55
network::EventDispatcher & dispatcher_
Reference to the central EventDispatcher (Reactor) singleton.
Definition Server.hpp:58
~Server()
Definition Server.cpp:69
void setupAcceptors()
Definition Server.cpp:111
void gracefulShutdown()
Definition Server.cpp:99
void requestShutDown()
Definition Server.cpp:142
http::MimeTypes mimeTypes_
MIME types database instance (passed to the router).
Definition Server.hpp:59
void stop()
Definition Server.cpp:93
volatile sig_atomic_t shutdownRequested_
Graceful shutdown flag (must be volatile sig_atomic_t for signal handler).
Definition Server.hpp:54
bool isRunning_
Tracks main loop state (true between start() and gracefulShutdown()).
Definition Server.hpp:53
Server(config::ServerConfig const &)
Definition Server.cpp:52
int nullFd_
Server-wide file descriptor for /dev/null (opened at startup).
Definition Server.hpp:62
void cleanup()
Definition Server.cpp:132
void start()
Definition Server.cpp:78
Definition MimeTypes.hpp:11
The central request dispatcher (Facade).
Definition Router.hpp:20
Centralised event demultiplexer and dispatcher for managing I/O events.
Definition EventDispatcher.hpp:19
Definition Server.hpp:11