Add rebuild output logging for debugging
Redirect nixos-rebuild stdout/stderr to /var/log/cm-dashboard/nixos-rebuild.log while keeping the process detached. This allows monitoring rebuild progress and debugging why cargo builds in /tmp aren't visible when agent runs. Use: tail -f /var/log/cm-dashboard/nixos-rebuild.log to monitor progress.
This commit is contained in:
parent
16ea853f5b
commit
1b3f8671c0
@ -296,9 +296,15 @@ impl Agent {
|
|||||||
// Clone or update repository
|
// Clone or update repository
|
||||||
let git_result = self.ensure_git_repository(git_url, git_branch, working_dir, api_key_file).await;
|
let git_result = self.ensure_git_repository(git_url, git_branch, working_dir, api_key_file).await;
|
||||||
|
|
||||||
// Execute nixos-rebuild if git operation succeeded - run detached to avoid killing current agent
|
// Execute nixos-rebuild if git operation succeeded - run detached but log output
|
||||||
let rebuild_result = if git_result.is_ok() {
|
let rebuild_result = if git_result.is_ok() {
|
||||||
info!("Git repository ready, executing nixos-rebuild in detached mode");
|
info!("Git repository ready, executing nixos-rebuild in detached mode");
|
||||||
|
let log_file = std::fs::OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.append(true)
|
||||||
|
.open("/var/log/cm-dashboard/nixos-rebuild.log")
|
||||||
|
.map_err(|e| anyhow::anyhow!("Failed to open rebuild log: {}", e))?;
|
||||||
|
|
||||||
tokio::process::Command::new("nohup")
|
tokio::process::Command::new("nohup")
|
||||||
.arg("sudo")
|
.arg("sudo")
|
||||||
.arg("/run/current-system/sw/bin/nixos-rebuild")
|
.arg("/run/current-system/sw/bin/nixos-rebuild")
|
||||||
@ -310,8 +316,8 @@ impl Agent {
|
|||||||
.arg(".")
|
.arg(".")
|
||||||
.current_dir(working_dir)
|
.current_dir(working_dir)
|
||||||
.stdin(std::process::Stdio::null())
|
.stdin(std::process::Stdio::null())
|
||||||
.stdout(std::process::Stdio::null())
|
.stdout(std::process::Stdio::from(log_file.try_clone().unwrap()))
|
||||||
.stderr(std::process::Stdio::null())
|
.stderr(std::process::Stdio::from(log_file))
|
||||||
.spawn()
|
.spawn()
|
||||||
} else {
|
} else {
|
||||||
return git_result.and_then(|_| unreachable!());
|
return git_result.and_then(|_| unreachable!());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user