diff options
| author | diogo464 <[email protected]> | 2025-07-11 14:59:29 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-07-11 14:59:29 +0100 |
| commit | 85e2c67272d4b7494127d833c8f44eb9e3a11bd4 (patch) | |
| tree | d1c90a317aeb1cd35f4b3a98d5fc5b2c8b00cbc0 | |
| parent | 16320eed1185b911d53bfe5aa77e43b7af02b358 (diff) | |
fixed reading schedule from stdin
| -rw-r--r-- | src/main.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index f05dad9..6237695 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -235,6 +235,7 @@ fn parse_schedule(schedule: &str) -> Result<Vec<ScheduledContainer>> { | |||
| 235 | env: HashMap<String, String>, | 235 | env: HashMap<String, String>, |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | tracing::trace!("parsing schedule:\n{schedule}"); | ||
| 238 | let items = serde_json::from_str::<Vec<ScheduleItem>>(schedule)?; | 239 | let items = serde_json::from_str::<Vec<ScheduleItem>>(schedule)?; |
| 239 | let mut containers = Vec::default(); | 240 | let mut containers = Vec::default(); |
| 240 | for item in items { | 241 | for item in items { |
| @@ -257,12 +258,15 @@ fn parse_schedule(schedule: &str) -> Result<Vec<ScheduledContainer>> { | |||
| 257 | 258 | ||
| 258 | async fn cmd_run(args: RunArgs) -> Result<()> { | 259 | async fn cmd_run(args: RunArgs) -> Result<()> { |
| 259 | let ctx = context_from_common(&args.common).await?; | 260 | let ctx = context_from_common(&args.common).await?; |
| 260 | let machines = oar::job_list_machines(&ctx).await?; | ||
| 261 | let schedule = match args.schedule { | 261 | let schedule = match args.schedule { |
| 262 | Some(path) => tokio::fs::read_to_string(&path) | 262 | Some(path) => { |
| 263 | .await | 263 | tracing::debug!("reading schedule from {}", path.display()); |
| 264 | .with_context(|| format!("reading schedule file: {}", path.display()))?, | 264 | tokio::fs::read_to_string(&path) |
| 265 | .await | ||
| 266 | .with_context(|| format!("reading schedule file: {}", path.display()))? | ||
| 267 | } | ||
| 265 | None => { | 268 | None => { |
| 269 | tracing::debug!("reading schedule from stdin"); | ||
| 266 | let mut stdin = String::default(); | 270 | let mut stdin = String::default(); |
| 267 | tokio::io::stdin() | 271 | tokio::io::stdin() |
| 268 | .read_to_string(&mut stdin) | 272 | .read_to_string(&mut stdin) |
| @@ -272,6 +276,7 @@ async fn cmd_run(args: RunArgs) -> Result<()> { | |||
| 272 | } | 276 | } |
| 273 | }; | 277 | }; |
| 274 | let containers = parse_schedule(&schedule)?; | 278 | let containers = parse_schedule(&schedule)?; |
| 279 | let machines = oar::job_list_machines(&ctx).await?; | ||
| 275 | 280 | ||
| 276 | machine::for_each(&machines, |machine| machine_containers_clean(&ctx, machine)).await?; | 281 | machine::for_each(&machines, |machine| machine_containers_clean(&ctx, machine)).await?; |
| 277 | machine::for_each(&machines, |machine| { | 282 | machine::for_each(&machines, |machine| { |
