@@ -389,23 +389,7 @@ void HttpServerStart(DatabaseInstance& db, string_t host, int32_t port, string_t
389
389
390
390
if (run_in_same_thread) {
391
391
#ifdef _WIN32
392
- // Windows-specific handler for Ctrl+C
393
- BOOL WINAPI consoleHandler (DWORD signal ) {
394
- if (signal == CTRL_C_EVENT) {
395
- if (global_state.server ) {
396
- global_state.server ->stop ();
397
- }
398
- global_state.is_running = false ; // Update the running state
399
- return TRUE ; // Indicate that the signal was handled
400
- }
401
- return FALSE ;
402
- }
403
-
404
- // Set the console control handler for Windows
405
- if (!SetConsoleCtrlHandler (consoleHandler, TRUE )) {
406
- std::cerr << " Error setting up signal handler" << std::endl;
407
- throw IOException (" Failed to set up signal handler" );
408
- }
392
+ throw IOException (" Foreground mode not yet supported on WIN32 platforms." );
409
393
#else
410
394
// POSIX signal handler for SIGINT (Linux/macOS)
411
395
signal (SIGINT, [](int ) {
@@ -414,14 +398,14 @@ void HttpServerStart(DatabaseInstance& db, string_t host, int32_t port, string_t
414
398
}
415
399
global_state.is_running = false ; // Update the running state
416
400
});
417
- #endif
418
-
401
+
419
402
// Run the server in the same thread
420
403
if (!global_state.server ->listen (host_str.c_str (), port)) {
421
404
global_state.is_running = false ;
422
405
throw IOException (" Failed to start HTTP server on " + host_str + " :" + std::to_string (port));
423
406
}
424
-
407
+ #endif
408
+
425
409
// The server has stopped (due to CTRL-C or other reasons)
426
410
global_state.is_running = false ;
427
411
} else {
0 commit comments