mirror of
https://github.com/BloopAI/dev-manager-mcp.git
synced 2026-08-23 11:58:33 +00:00
The stop command doesn't kill the dev server (vibe-kanban 3b4e5e08)
I notice when the client tries to use the stop command, it doesn't always stop the dev server that's running
This commit is contained in:
@@ -154,9 +154,28 @@ impl Manager {
|
||||
c.arg("/C").arg(&command);
|
||||
c
|
||||
} else {
|
||||
let mut c = Command::new("sh");
|
||||
c.arg("-c").arg(&command);
|
||||
c
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let mut c = Command::new("sh");
|
||||
c.arg("-c").arg(&command);
|
||||
unsafe {
|
||||
#[allow(unused_imports)]
|
||||
use std::os::unix::process::CommandExt;
|
||||
c.pre_exec(|| {
|
||||
if libc::setsid() == -1 {
|
||||
return Err(std::io::Error::last_os_error());
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
c
|
||||
}
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
let mut c = Command::new("sh");
|
||||
c.arg("-c").arg(&command);
|
||||
c
|
||||
}
|
||||
};
|
||||
cmd.stdout(std::process::Stdio::piped());
|
||||
cmd.stderr(std::process::Stdio::piped());
|
||||
|
||||
@@ -84,12 +84,35 @@ impl ServerEntry {
|
||||
|
||||
pub async fn stop(&mut self) -> anyhow::Result<()> {
|
||||
if let ProcessState::Running(child) = &mut self.state {
|
||||
child.kill().await?;
|
||||
|
||||
match timeout(Duration::from_secs(5), child.wait()).await {
|
||||
Ok(Ok(_)) => {},
|
||||
Ok(Err(e)) => return Err(e.into()),
|
||||
Err(_) => anyhow::bail!("Timeout waiting for process to exit"),
|
||||
#[cfg(unix)]
|
||||
{
|
||||
if let Some(pid) = child.id() {
|
||||
let pgid = -(pid as i32);
|
||||
unsafe {
|
||||
libc::kill(pgid, libc::SIGTERM);
|
||||
}
|
||||
}
|
||||
|
||||
if timeout(Duration::from_secs(5), child.wait()).await.is_err() {
|
||||
if let Some(pid) = child.id() {
|
||||
let pgid = -(pid as i32);
|
||||
unsafe {
|
||||
libc::kill(pgid, libc::SIGKILL);
|
||||
}
|
||||
}
|
||||
let _ = timeout(Duration::from_secs(2), child.wait()).await;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if let Some(pid) = child.id() {
|
||||
let _ = tokio::process::Command::new("taskkill")
|
||||
.args(["/PID", &pid.to_string(), "/T", "/F"])
|
||||
.status()
|
||||
.await;
|
||||
}
|
||||
let _ = timeout(Duration::from_secs(5), child.wait()).await;
|
||||
}
|
||||
|
||||
self.state = ProcessState::Exited {
|
||||
|
||||
Reference in New Issue
Block a user