27 lines
436 B
C++
27 lines
436 B
C++
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <atomic>
|
||
|
|
#include <string>
|
||
|
|
#include <thread>
|
||
|
|
|
||
|
|
#include "app_config.hpp"
|
||
|
|
|
||
|
|
class ConfigServer
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
ConfigServer() = default;
|
||
|
|
~ConfigServer();
|
||
|
|
|
||
|
|
bool start(const std::string& config_path);
|
||
|
|
void stop();
|
||
|
|
|
||
|
|
private:
|
||
|
|
void run();
|
||
|
|
void handle_client(int client_fd);
|
||
|
|
|
||
|
|
std::string config_path_;
|
||
|
|
std::thread thread_;
|
||
|
|
std::atomic<bool> running_{false};
|
||
|
|
int server_fd_ = -1;
|
||
|
|
};
|