Fix rebuild_and_restart in Docker by using cargo output path
Use the known cargo build output path instead of current_exe() when re-execing after a rebuild. In Docker, the running binary lives at /usr/local/bin/storkit (read-only) while cargo writes the new binary to /app/target/release/storkit (a writable volume), so current_exe() would just restart the old binary. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -70,9 +70,15 @@ pub async fn rebuild_and_restart(agents: &AgentPool, project_root: &Path) -> Res
|
|||||||
slog!("[rebuild] Build succeeded, re-execing with new binary");
|
slog!("[rebuild] Build succeeded, re-execing with new binary");
|
||||||
|
|
||||||
// 4. Re-exec with the new binary.
|
// 4. Re-exec with the new binary.
|
||||||
// Collect current argv so we preserve any CLI arguments (e.g. project path).
|
// Use the cargo output path rather than current_exe() so that rebuilds
|
||||||
let current_exe =
|
// inside Docker work correctly — the running binary may be installed at
|
||||||
std::env::current_exe().map_err(|e| format!("Cannot determine current executable: {e}"))?;
|
// /usr/local/bin/storkit (read-only) while cargo writes the new binary
|
||||||
|
// to /app/target/release/storkit (a writable volume).
|
||||||
|
let new_exe = if cfg!(debug_assertions) {
|
||||||
|
workspace_root.join("target/debug/storkit")
|
||||||
|
} else {
|
||||||
|
workspace_root.join("target/release/storkit")
|
||||||
|
};
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
|
||||||
// Remove the port file before re-exec so the new process can write its own.
|
// Remove the port file before re-exec so the new process can write its own.
|
||||||
@@ -89,7 +95,7 @@ pub async fn rebuild_and_restart(agents: &AgentPool, project_root: &Path) -> Res
|
|||||||
// Use exec() to replace the current process.
|
// Use exec() to replace the current process.
|
||||||
// This never returns on success.
|
// This never returns on success.
|
||||||
use std::os::unix::process::CommandExt;
|
use std::os::unix::process::CommandExt;
|
||||||
let err = std::process::Command::new(¤t_exe)
|
let err = std::process::Command::new(&new_exe)
|
||||||
.args(&args[1..])
|
.args(&args[1..])
|
||||||
.exec();
|
.exec();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user