58 lines
1.2 KiB
Rust
58 lines
1.2 KiB
Rust
use crate::definition::Project;
|
|
use actix::prelude::*;
|
|
use arkham::{App, Command};
|
|
use runner::Manager;
|
|
use std::env;
|
|
use std::path::{Path, PathBuf};
|
|
|
|
mod definition;
|
|
mod job;
|
|
mod runner;
|
|
|
|
#[actix_rt::main]
|
|
async fn main() {
|
|
let project = Project::from_str(
|
|
r#"
|
|
components:
|
|
- name: ls
|
|
commands:
|
|
- ls
|
|
- name: currentdir
|
|
commands:
|
|
- pwd
|
|
"#,
|
|
);
|
|
let jobs = project.get_by_name("ls").unwrap();
|
|
let manager = Manager::new().start();
|
|
manager.do_send(jobs);
|
|
|
|
find_config("conductor.yml");
|
|
|
|
actix_rt::signal::ctrl_c()
|
|
.await
|
|
.expect("failed to listen for event");
|
|
}
|
|
|
|
fn find_config(config: &str) -> Option<PathBuf> {
|
|
env::current_dir()
|
|
.map(|dir| find_file(&dir, config))
|
|
.unwrap_or(None)
|
|
}
|
|
|
|
fn find_file(starting_directory: &Path, filename: &str) -> Option<PathBuf> {
|
|
let mut path: PathBuf = starting_directory.into();
|
|
let file = Path::new(&filename);
|
|
|
|
loop {
|
|
path.push(file);
|
|
|
|
if path.is_file() {
|
|
break Some(path);
|
|
}
|
|
|
|
if !(path.pop() && path.pop()) {
|
|
break None;
|
|
}
|
|
}
|
|
}
|