Spaces:
Building
Building
Dmitry Beresnev
Refactor the C++ LLM manager into modular components, moves Python modules under python/, and keeps the current control-plane behavior intact. The C++ server now has clearer separation for config, model lifecycle, runtime services, request parsing, HTTP helpers, and server routing, while Docker build/runtime paths were updated to compile multiple C++ files and load Python code from the new package folder
332826f | namespace asio = boost::asio; | |
| int main() { | |
| const ManagerConfig config = load_manager_config(); | |
| const auto &bind_host = config.server.host; | |
| const int bind_port = config.server.port; | |
| ModelManager manager(config); | |
| ApiKeyAuth auth(config); | |
| RateLimiterStore rate_limiter(config.rate_limit); | |
| RequestRegistry registry; | |
| MetricsRegistry metrics; | |
| Scheduler scheduler(manager, registry, metrics, config.queue); | |
| std::string init_error; | |
| if (auth.enabled()) { | |
| log_line("auth: enabled api_keys=" + std::to_string(config.api_keys.size())); | |
| } else { | |
| log_line("auth: disabled (no configured api keys)"); | |
| } | |
| log_line("startup: loading default model"); | |
| if (!manager.initialize_default(init_error)) { | |
| log_line("startup: default model failed: " + init_error); | |
| } else { | |
| log_line("startup: default model ready"); | |
| } | |
| asio::io_context ioc{1}; | |
| asio::ip::tcp::acceptor acceptor{ | |
| ioc, | |
| {asio::ip::make_address(bind_host), static_cast<unsigned short>(bind_port)}}; | |
| log_line("manager listening on " + bind_host + ":" + std::to_string(bind_port)); | |
| for (;;) { | |
| asio::ip::tcp::socket socket{ioc}; | |
| acceptor.accept(socket); | |
| std::thread( | |
| &do_session, | |
| std::move(socket), | |
| std::ref(manager), | |
| std::cref(config), | |
| std::cref(auth), | |
| std::ref(rate_limiter), | |
| std::ref(registry), | |
| std::ref(metrics), | |
| std::ref(scheduler)).detach(); | |
| } | |
| } | |