mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix server crashing on Lua errors
Previously, the server called FATAL_ERROR when a Lua error occured. This caused a (mostly useless) core dump. The server now simply throws an exception, which is caught and printed before exiting with a non-zero return value. This also fixes a number of instances where errors were logged multiple times.
This commit is contained in:
parent
b872df6ef6
commit
9269a0ecc7
10 changed files with 58 additions and 80 deletions
22
src/main.cpp
22
src/main.cpp
|
@ -816,14 +816,22 @@ static bool run_dedicated_server(const GameParams &game_params, const Settings &
|
|||
if (cmd_args.exists("migrate"))
|
||||
return migrate_database(game_params, cmd_args);
|
||||
|
||||
// Create server
|
||||
Server server(game_params.world_path, game_params.game_spec, false,
|
||||
bind_addr.isIPv6());
|
||||
server.start(bind_addr);
|
||||
try {
|
||||
// Create server
|
||||
Server server(game_params.world_path, game_params.game_spec, false,
|
||||
bind_addr.isIPv6());
|
||||
server.start(bind_addr);
|
||||
|
||||
// Run server
|
||||
bool &kill = *porting::signal_handler_killstatus();
|
||||
dedicated_server_loop(server, kill);
|
||||
// Run server
|
||||
bool &kill = *porting::signal_handler_killstatus();
|
||||
dedicated_server_loop(server, kill);
|
||||
} catch (const ModError &e) {
|
||||
errorstream << "ModError: " << e.what() << std::endl;
|
||||
return false;
|
||||
} catch (const ServerError &e) {
|
||||
errorstream << "ServerError: " << e.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue