mirror of
https://github.com/timvisee/lazymc.git
synced 2025-05-19 04:40:22 -07:00
Scuffed code, not tested yet
This commit is contained in:
parent
d3cb880dd0
commit
b561351a2a
@ -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."
|
||||
);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user