Compare commits
3 Commits
02c34b30fd
...
9a39ea00d6
Author | SHA1 | Date |
---|---|---|
R Tyler Croy | 9a39ea00d6 | |
R Tyler Croy | 8b58f69b5e | |
R Tyler Croy | 07f1dadea2 |
|
@ -175,9 +175,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "async-io"
|
||||
version = "1.2.0"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40a0b2bb8ae20fede194e779150fe283f65a4a08461b496de546ec366b174ad9"
|
||||
checksum = "458c8f66c246624e7cf87c01451f3392ab77d66a0f105a49d9353b30ea97ced8"
|
||||
dependencies = [
|
||||
"concurrent-queue",
|
||||
"fastrand",
|
||||
|
@ -2303,9 +2303,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.51"
|
||||
version = "1.0.52"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b4f34193997d92804d359ed09953e25d5138df6bcc055a71bf68ee89fdf9223"
|
||||
checksum = "6c1e438504729046a5cfae47f97c30d6d083c7d91d94603efdae3477fc070d4c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
@ -78,9 +78,12 @@ async fn main() -> std::io::Result<()> {
|
|||
panic!("Failed to parse parameters file: {:#?}", e);
|
||||
}
|
||||
Ok(invoke) => {
|
||||
async_std::task::spawn(async {
|
||||
let pipeline_uuid = invoke.pipeline.clone();
|
||||
async_std::task::spawn(async move {
|
||||
// TODO better error handling and behavior
|
||||
control::run(sender).await.expect("Failed to bind control?");
|
||||
control::run(pipeline_uuid, sender)
|
||||
.await
|
||||
.expect("Failed to bind control?");
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -93,9 +96,12 @@ async fn main() -> std::io::Result<()> {
|
|||
|
||||
set_common_env_vars();
|
||||
|
||||
run(&steps_dir, &invoke.steps, invoke.pipeline, Some(receiver))
|
||||
let status = run(&steps_dir, &invoke.steps, invoke.pipeline, Some(receiver))
|
||||
.expect("Failed to run pipeline");
|
||||
|
||||
println!("Agent exiting {:?}", status);
|
||||
|
||||
std::process::exit(status as i32);
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
use async_std::sync::Sender;
|
||||
use log::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
|
@ -27,9 +28,9 @@ async fn handle_request(mut req: tide::Request<State>) -> tide::Result {
|
|||
Ok("{}".into())
|
||||
}
|
||||
|
||||
pub async fn run(sender: Sender<Request>) -> tide::Result<()> {
|
||||
pub async fn run(pipeline: Uuid, sender: Sender<Request>) -> tide::Result<()> {
|
||||
info!("Starting the agent control server");
|
||||
let sock = agent_socket();
|
||||
let sock = agent_socket(&pipeline);
|
||||
let state = State { sender };
|
||||
let mut app = tide::with_state(state);
|
||||
|
||||
|
@ -53,9 +54,11 @@ pub async fn run(sender: Sender<Request>) -> tide::Result<()> {
|
|||
/**
|
||||
* Return a string representing the absolute path of this agent's control socket
|
||||
*/
|
||||
pub fn agent_socket() -> std::path::PathBuf {
|
||||
let path = std::env::current_dir().expect("Failed to get current directory");
|
||||
path.join("agent.sock").to_path_buf()
|
||||
pub fn agent_socket(pipeline: &Uuid) -> std::path::PathBuf {
|
||||
let uuid = pipeline.to_hyphenated().to_string();
|
||||
std::env::temp_dir()
|
||||
.join(format!("{}-agent.sock", uuid))
|
||||
.to_path_buf()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -64,7 +67,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_agent_sock() {
|
||||
let buf = agent_socket();
|
||||
let uuid = uuid::Uuid::new_v4();
|
||||
let buf = agent_socket(&uuid);
|
||||
assert!(buf.to_string_lossy().ends_with("agent.sock"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ pub fn run(
|
|||
};
|
||||
|
||||
// TODO: This is going to be wrong on nested steps
|
||||
let sock = control::agent_socket();
|
||||
let sock = control::agent_socket(&pipeline);
|
||||
let configuration = step::Configuration {
|
||||
pipeline: pipeline,
|
||||
uuid: step.uuid,
|
||||
|
|
Loading…
Reference in New Issue