Skip to content

Commit

Permalink
fix: log_file use at start service (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
biswaroop1547 authored Oct 26, 2023
1 parent 61a09d6 commit 8f199b9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src-tauri/src/controller_binaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::errors::{Context, Result};
use crate::{Service, SharedState};
use std::collections::HashMap;
use std::path::PathBuf;
use std::process::Stdio;
use sys_info::mem_info;

use futures::future;
Expand Down Expand Up @@ -61,7 +60,7 @@ pub async fn start_service(
let log_path = PathBuf::from(&service_dir).join(format!("{}.log", service_id));

// Use synchronous std::fs::File for log file creation
let _log_file = std::fs::OpenOptions::new()
let log_file = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open(&log_path)
Expand Down Expand Up @@ -117,8 +116,12 @@ pub async fn start_service(
let child = Command::new(&binary_path)
.current_dir(service_dir)
.args(args)
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.stdout(std::process::Stdio::from(
log_file
.try_clone()
.with_context(|| "Failed to clone log file handle")?,
))
.stderr(std::process::Stdio::from(log_file))
.spawn()
.map_err(|e| format!("Failed to spawn child process: {}", e))?;
let mut running_services_guard = state.running_services.lock().await;
Expand Down

0 comments on commit 8f199b9

Please sign in to comment.