This commit is contained in:
bumpsoo 2026-02-03 09:44:08 +00:00
commit b887f15662
21 changed files with 1038 additions and 0 deletions

45
src/main.cpp Normal file
View file

@ -0,0 +1,45 @@
#include "DatabaseManager.h"
#include "Logger.h"
#include "NetworkService.h"
#include <csignal>
int main() {
try {
uint16_t port = 30000;
uint32_t threadCount = std::thread::hardware_concurrency();
if (threadCount == 0)
threadCount = 1;
boost::asio::io_context main_context;
if (!DatabaseManager::GetInstance().Init(main_context, "127.0.0.1", 33306,
"root", "root_password",
"socket_server")) {
Logger::Log("경고: 초기 DB 연결에 실패했습니다. (서버는 계속 실행됨)");
}
NetworkService server(port, threadCount);
server.Run();
boost::asio::signal_set signals(main_context, SIGINT, SIGTERM);
Logger::Log("서버가 실행 중입니다. (종료: Ctrl+C)");
signals.async_wait(
[&server, &main_context](const boost::system::error_code &error,
int signal_number) {
if (!error) {
Logger::Log("\n종료 시그널 수신 (", signal_number,
"). 서버를 중지합니다...");
server.Stop();
main_context.stop();
}
});
main_context.run();
} catch (std::exception &e) {
Logger::Log("Exception: ", e.what());
}
return 0;
}