diff --git a/src/TServer.cpp b/src/TServer.cpp index badd95d..b0ec172 100644 --- a/src/TServer.cpp +++ b/src/TServer.cpp @@ -160,7 +160,6 @@ TEST_CASE("ParseVehiclePacket") { } TServer::TServer(const std::vector& Arguments) { - beammp_infof("BeamMP Server v{} ({})", Application::ServerVersionString(), BEAMMP_GIT_HASH); Application::SetSubsystemStatus("Server", Application::Status::Starting); if (Arguments.size() > 1) { Application::SetSetting(StrCustomIP, std::string(Arguments[0])); diff --git a/src/main.cpp b/src/main.cpp index 65b4fd6..4513420 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -112,14 +112,28 @@ int BeamMPServerMain(MainArguments Arguments) { } } - Application::Console().Internal().set_prompt("> "); Application::SetSubsystemStatus("Main", Application::Status::Starting); - Application::Console().StartLoggingToFile(); - SetupSignalHandlers(); + + beammp_infof("BeamMP Server v{} ({})", Application::ServerVersionString(), BEAMMP_GIT_HASH); + TConfig Config(ConfigPath); + + if (Config.Failed()) { + beammp_info("Closing in 10 seconds"); + // loop to make it possible to ctrl+c instead + Application::SleepSafeSeconds(5); + beammp_info("Closing in 5 seconds"); + Application::SleepSafeSeconds(5); + Application::GracefullyShutdown(); + return 1; + } + + Application::Console().Internal().set_prompt("> "); + Application::Console().StartLoggingToFile(); + bool Shutdown = false; Application::RegisterShutdownHandler([&Shutdown] { beammp_info("If this takes too long, you can press Ctrl+C repeatedly to force a shutdown."); @@ -130,22 +144,12 @@ int BeamMPServerMain(MainArguments Arguments) { auto Futures = LuaAPI::MP::Engine->TriggerEvent("onShutdown", ""); TLuaEngine::WaitForAll(Futures, std::chrono::seconds(5)); }); - + TServer Server(Arguments.List); - TConfig Config(ConfigPath); auto LuaEngine = std::make_shared(); LuaEngine->SetServer(&Server); Application::Console().InitializeLuaConsole(*LuaEngine); - if (Config.Failed()) { - beammp_info("Closing in 10 seconds"); - // loop to make it possible to ctrl+c instead - for (size_t i = 0; i < 20; ++i) { - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - } - return 1; - } - RegisterThread("Main"); beammp_trace("Running in debug mode on a debug build");