mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-28 22:21:33 +02:00
Add detailed logging to process holder
This commit is contained in:
parent
9a736c5eb9
commit
2a9ee4de0b
@ -1,6 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use tokio::sync::RwLock;
|
||||
use tracing::trace;
|
||||
|
||||
use crate::{command::Supervisor, error::RuntimeError, signal::process::SubSignal};
|
||||
|
||||
@ -21,31 +22,50 @@ impl ProcessHolder {
|
||||
}
|
||||
|
||||
pub async fn drop_inner(&self) {
|
||||
trace!("dropping supervisor");
|
||||
self.0.write().await.take();
|
||||
trace!("dropped supervisor");
|
||||
}
|
||||
|
||||
pub async fn replace(&self, new: Supervisor) {
|
||||
trace!("replacing supervisor");
|
||||
if let Some(_old) = self.0.write().await.replace(new) {
|
||||
trace!("replaced supervisor");
|
||||
// TODO: figure out what to do with old
|
||||
} else {
|
||||
trace!("not replaced: no supervisor");
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn signal(&self, sig: SubSignal) {
|
||||
if let Some(p) = self.0.read().await.as_ref() {
|
||||
trace!("signaling supervisor");
|
||||
p.signal(sig).await;
|
||||
trace!("signaled supervisor");
|
||||
} else {
|
||||
trace!("not signaling: no supervisor");
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn kill(&self) {
|
||||
if let Some(p) = self.0.read().await.as_ref() {
|
||||
trace!("killing supervisor");
|
||||
p.kill().await;
|
||||
trace!("killed supervisor");
|
||||
} else {
|
||||
trace!("not killing: no supervisor");
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn wait(&self) -> Result<(), RuntimeError> {
|
||||
if let Some(p) = self.0.read().await.as_ref() {
|
||||
trace!("waiting on supervisor");
|
||||
p.wait().await?;
|
||||
trace!("waited on supervisor");
|
||||
} else {
|
||||
trace!("not waiting: no supervisor");
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user