Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"download",
"factory/aws",
"factory/gimlet",
"factory/user",
"factory/lab",
"factory/propolis",
"github/client",
Expand Down Expand Up @@ -44,6 +45,7 @@ wrong_self_convention = "allow"
[workspace.dependencies]
ansi-to-html = { version = "0.2", features = [ "lazy-init" ] }
anyhow = "1"
async-compression = { version = "0.4", features = ["gzip", "tokio"] }
aws-config = "1"
aws-credential-types = "1"
aws-runtime = "1"
Expand All @@ -58,6 +60,7 @@ devinfo = { version = "0.1", features = [ "private" ] }
dialoguer = { version = "0.12.0", default-features = false }
dirs-next = "2"
dropshot = "0.16"
expect-test = "1"
futures = "0.3"
futures-core = "0.3"
getopts = "0.2"
Expand All @@ -80,6 +83,7 @@ percent-encoding = "2.1"
progenitor = { version = "0.11" }
progenitor-client = { version = "0.11" }
rand = "0.10"
rand_pcg = "0.10"
regex = "1"
reqwest = { version = "0.12", features = [ "json", "stream" ] }
rust-toolchain-file = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion agent/smf/agent.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</dependency>

<exec_method name='start' type='method' timeout_seconds='60'
exec='/opt/buildomat/lib/start.sh'/>
exec='%START_SCRIPT%'/>
<exec_method name='stop' type='method' timeout_seconds='60'
exec=':kill'/>

Expand Down
2 changes: 1 addition & 1 deletion agent/smf/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ exec /usr/bin/ctrun \
-l child \
-o noorphan,regent \
\
/opt/buildomat/lib/agent run
%AGENT_BIN% run
6 changes: 3 additions & 3 deletions agent/src/control/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ use tokio::{
net::UnixStream,
};

use crate::InstallLocation;
use protocol::{
Decoder, FactoryInfo, Message, Payload, PayloadReq, PayloadRes,
};

pub(crate) mod protocol;
pub(crate) mod server;

pub const SOCKET_PATH: &str = "/var/run/buildomat.sock";

struct Stuff {
us: Option<UnixStream>,
dec: Option<Decoder>,
Expand All @@ -30,7 +29,8 @@ struct Stuff {

impl Stuff {
async fn connect(&mut self) -> Result<()> {
self.us = Some(UnixStream::connect(SOCKET_PATH).await?);
let loc = InstallLocation::detect()?;
self.us = Some(UnixStream::connect(loc.control_sock()).await?);
self.dec = Some(Decoder::new());
Ok(())
}
Expand Down
16 changes: 8 additions & 8 deletions agent/src/control/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ use tokio::{
},
};

use super::{
protocol::{Decoder, Message, Payload, PayloadReq, PayloadRes},
SOCKET_PATH,
};
use super::protocol::{Decoder, Message, Payload, PayloadReq, PayloadRes};
use crate::InstallLocation;

#[derive(Debug)]
pub struct Request {
Expand Down Expand Up @@ -48,19 +46,21 @@ impl Request {
}

pub fn listen() -> Result<Receiver<Request>> {
let loc = InstallLocation::detect()?;

/*
* Create the UNIX socket that the control program will use to contact the
* agent.
*/
std::fs::remove_file(SOCKET_PATH).ok();
let ul = UnixListener::bind(SOCKET_PATH)?;
std::fs::remove_file(loc.control_sock()).ok();
let ul = UnixListener::bind(loc.control_sock())?;

/*
* Allow everyone to connect:
*/
let mut perm = std::fs::metadata(SOCKET_PATH)?.permissions();
let mut perm = std::fs::metadata(loc.control_sock())?.permissions();
perm.set_mode(0o777);
std::fs::set_permissions(SOCKET_PATH, perm)?;
std::fs::set_permissions(loc.control_sock(), perm)?;

/*
* Create channel to hand requests back to the main loop.
Expand Down
Loading