|
Webserv
|
High-level server orchestrator that manages the complete server lifecycle. More...
#include <Server.hpp>
Public Member Functions | |
| Server (config::ServerConfig const &) | |
| ~Server () | |
| void | start () |
| void | stop () |
| bool | getisRunning () const |
| void | requestShutDown () |
Static Public Member Functions | |
| static int | getNullFd () |
| Gets the server-wide file descriptor for /dev/null. | |
Private Member Functions | |
| void | setupAcceptors () |
| void | cleanup () |
| void | gracefulShutdown () |
| Server (const Server &) | |
| Server & | operator= (const Server &) |
Private Attributes | |
| bool | isRunning_ |
| Tracks main loop state (true between start() and gracefulShutdown()). | |
| volatile sig_atomic_t | shutdownRequested_ |
| Graceful shutdown flag (must be volatile sig_atomic_t for signal handler). | |
| std::vector< network::Acceptor * > | acceptors_ |
| Collection of active acceptor handlers (listening sockets). | |
| config::ServerConfig const & | config_ |
| Const reference to the parsed server configuration. | |
| network::EventDispatcher & | dispatcher_ |
| Reference to the central EventDispatcher (Reactor) singleton. | |
| http::MimeTypes | mimeTypes_ |
| MIME types database instance (passed to the router). | |
| http::Router | router_ |
| HTTP request router for dispatching requests to handlers. | |
| int | nullFd_ |
| Server-wide file descriptor for /dev/null (opened at startup). | |
High-level server orchestrator that manages the complete server lifecycle.
The Server class acts as a Facade for the underlying network subsystem. It hides the complexity of the Reactor pattern (e.g., EventDispatcher, Acceptors) behind a simple start() and stop() interface.
This class is the central point of control and is responsible for:
It is implemented as a Singleton (using instance_) to allow the static signalHandler to access the active Server instance and request a shutdown.
|
explicit |
| core::Server::~Server | ( | ) |
|
private |
|
private |
| bool core::Server::getisRunning | ( | ) | const |
|
static |
Gets the server-wide file descriptor for /dev/null.
|
private |
| void core::Server::requestShutDown | ( | ) |
|
private |
| void core::Server::start | ( | ) |
| void core::Server::stop | ( | ) |
|
private |
Collection of active acceptor handlers (listening sockets).
|
private |
Const reference to the parsed server configuration.
|
private |
Reference to the central EventDispatcher (Reactor) singleton.
|
private |
Tracks main loop state (true between start() and gracefulShutdown()).
|
private |
MIME types database instance (passed to the router).
|
private |
Server-wide file descriptor for /dev/null (opened at startup).
|
private |
HTTP request router for dispatching requests to handlers.
|
private |
Graceful shutdown flag (must be volatile sig_atomic_t for signal handler).