matdbg: fail gracefully, emit logs, fewer threads.

This commit is contained in:
Philip Rideout
2019-08-28 19:24:01 -07:00
parent b92c748fcc
commit 9c64c20ceb
6 changed files with 31 additions and 8 deletions

View File

@@ -345,11 +345,25 @@ DebugServer::DebugServer(ServerMode mode, int port) : mServerMode(mode) {
mCss = CString((const char*) MATDBG_RESOURCES_STYLE_DATA, MATDBG_RESOURCES_STYLE_SIZE - 1);
#endif
const char* kServerOptions[] = { "listening_ports", "8080", nullptr };
// By default the server spawns 50 threads so we override this to 2. This limits the server
// to having no more than 2 HTTP clients, which is perfectly fine for debugging purposes.
const char* kServerOptions[] = {
"listening_ports", "8080",
"num_threads", "2",
"error_log_file", "civetweb.txt",
nullptr
};
std::string portString = std::to_string(port);
kServerOptions[1] = portString.c_str();
mServer = new CivetServer(kServerOptions);
if (!mServer->getContext()) {
delete mServer;
mServer = nullptr;
slog.e << "Unable to start DebugServer, see civetweb.txt for details." << io::endl;
return;
}
mFileHandler = new FileRequestHandler(this);
mRestHandler = new RestRequestHandler(this);
mWebSocketHandler = new WebSocketHandler(this);