Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
brayniac committed Feb 5, 2025
1 parent 6577454 commit 18f301a
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/flight_recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ pub fn run(config: FlightRecorderConfig) {
// flush the extended file to disk
let _ = writer.flush();

// create the destination file and exit if it cannot be created
let _ = std::fs::File::create(config.output.clone())
.map_err(|e| {
error!("failed to open destination file: {e}");
std::process::exit(1);
})
.unwrap();

let mut idx = 0;

rt.block_on(async move {
Expand All @@ -168,13 +176,6 @@ pub fn run(config: FlightRecorderConfig) {
// sampling interval
let mut interval = tokio::time::interval_at(start, config.interval.into());
while STATE.load(Ordering::Relaxed) < TERMINATING {
let mut destination = std::fs::File::create(config.output.clone())
.map_err(|e| {
error!("failed to open destination file: {e}");
std::process::exit(1);
})
.unwrap();

// sample in a loop until RUNNING is false or duration has completed
while STATE.load(Ordering::Relaxed) == RUNNING {
// wait to sample
Expand Down Expand Up @@ -222,6 +223,14 @@ pub fn run(config: FlightRecorderConfig) {
debug!("flushing writer");
let _ = writer.flush();

// create the destination file
let mut destination = std::fs::File::create(config.output.clone())
.map_err(|e| {
error!("failed to open destination file: {e}");
std::process::exit(1);
})
.unwrap();

// handle any output format specific transforms
match config.format {
Format::Raw => {
Expand Down

0 comments on commit 18f301a

Please sign in to comment.