-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69b29aa
commit 52ce33d
Showing
5 changed files
with
148 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use log::{debug, warn}; | ||
use serenity::prelude::TypeMap; | ||
use tokio::sync::RwLockWriteGuard; | ||
|
||
use crate::data::Serv; | ||
|
||
/// get whether child has exit | ||
pub async fn poll_child<'a>(x: &mut RwLockWriteGuard<'a, TypeMap>) -> bool { | ||
let child_status = { | ||
let command = x.get_mut::<Serv>().expect("Could not unwrap data"); | ||
|
||
match &mut command.child_process { | ||
Some(process) => { | ||
debug!("Waiting for child process"); | ||
let res_return = process.try_wait(); | ||
match res_return { | ||
Ok(Some(_exit_code)) => { | ||
debug!("Exit code {}", _exit_code); | ||
true | ||
} | ||
Ok(None) => { | ||
debug!("Server has not exit yet"); | ||
false | ||
} | ||
Err(e) => { | ||
warn!("Could not wait for child process: {}", e.to_string()); | ||
true | ||
} | ||
} | ||
} | ||
None => { | ||
debug!("No child process for status command to query"); | ||
true | ||
} | ||
} | ||
}; | ||
child_status | ||
} |