Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Server Stop Logic #412

Open
1 task done
Yimura opened this issue Dec 26, 2024 · 3 comments
Open
1 task done

Inconsistent Server Stop Logic #412

Yimura opened this issue Dec 26, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@Yimura
Copy link
Contributor

Yimura commented Dec 26, 2024

I've searched existing issues and couldn't find a duplicate.

  • I confirm this is not a duplicate.

Operating System

Any

Server Software Version/Commit

master

What happened?

The stop command has a fairly normal logic of stopping the server and handling everything:

let kick_message = TextComponent::text("Server stopped");
for player in server.get_all_players().await {
player.kick(kick_message.clone()).await;
}
server.save().await;
std::process::exit(0)

However the signal handler is missing these player kicking and saving steps:

Pumpkin/pumpkin/src/main.rs

Lines 258 to 266 in febbfd8

fn handle_interrupt() {
log::warn!(
"{}",
TextComponent::text("Received interrupt signal; stopping server...")
.color_named(NamedColor::Red)
.to_pretty_console()
);
std::process::exit(0);
}

To Reproduce

Using the stop command results in a panic in the world saving logic (most likely because this hasn't been implemented but that's beside the point of this issue).

While ^C/SIGINT does not cause this crash and closes the server properly.

I'm mainly trying to highlight the difference in behaviour between the two shutdown methods.

Expected behavior

Centralise the logic of shutting the server down so there's no discrepancies between the server handling a stop command and it receiving a ^C/SIGINT/SIGTERM from the command line.

@Yimura Yimura added the bug Something isn't working label Dec 26, 2024
@Polygons1
Copy link
Contributor

stop issues are caused because of the dashmap crate, I have debugged it.

@Snowiiii
Copy link
Owner

I put that on the to do list already, I think we should use channels for something like that to send shutdowns when we need them. Also https://tokio.rs/tokio/topics/shutdown is useful

@Snowiiii
Copy link
Owner

I would be happy if someone may want to make a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants