mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-03 14:26:09 +00:00
fix server not closing after detecting an invalid config (fixes #151)
This commit is contained in:
@@ -160,7 +160,6 @@ TEST_CASE("ParseVehiclePacket") {
|
||||
}
|
||||
|
||||
TServer::TServer(const std::vector<std::string_view>& 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]));
|
||||
|
||||
32
src/main.cpp
32
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<TLuaEngine>();
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user