Scuffed code, not tested yet

This commit is contained in:
[object Object] 2022-12-28 12:18:43 -08:00
parent d3cb880dd0
commit b561351a2a
No known key found for this signature in database
GPG Key ID: F9ECDF22D7D28727
2 changed files with 43 additions and 2 deletions

View File

@ -39,3 +39,37 @@ pub fn kill_gracefully(pid: u32) -> bool {
"gracefully killing Minecraft server process not implemented on non-Unix platforms"
);
}
/// Freeze process.
/// Results in undefined behavior if PID is invaild.
///
/// # Panics
/// Panics on platforms other than Unix.
#[allow(unreachable_code)]
pub fn freeze(pid: u32) -> bool {
#[cfg(unix)]
unsafe {
return unix::freeze(pid);
}
unimplemented!(
"Freezing the Minecraft server process is not implemented on non-Unix platforms."
);
}
/// Unfreeze process.
/// Results in undefined behavior if PID is invaild.
///
/// # Panics
/// Panics on platforms other than Unix.
#[allow(unreachable_code)]
pub fn unfreeze(pid: u32) -> bool {
#[cfg(unix)]
unsafe {
return unix::unfreeze(pid);
}
unimplemented!(
"Unfreezing the Minecraft server process is not implemented on non-Unix platforms."
);
}

View File

@ -218,7 +218,10 @@ impl Server {
}
// Spawn server in new task
Self::spawn_server_task(config, server);
// TODO uncomment this and add config option
//Self::spawn_server_task(config, server);
// TODO actual error handling
os::unfreeze((*server.pid.lock().await).unwrap());
true
}
@ -587,9 +590,13 @@ async fn stop_server_signal(config: &Config, server: &Server) -> bool {
};
// Send kill signal
if !crate::os::kill_gracefully(pid) {
// TODO uncomment this and add a config option
/*if !crate::os::kill_gracefully(pid) {
error!(target: "lazymc", "Failed to send stop signal to server process");
return false;
}*/
if !os::freeze(pid) {
error!(target: "lazymc", "Failed to send freeze signal to server process.");
}
// Update from starting/started to stopping