Add support for build_timeout_seconds

This commit is contained in:
Graham Christensen 2017-11-24 13:03:52 -05:00
parent 1323890e07
commit 47f3bf00ff
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
4 changed files with 31 additions and 13 deletions

View file

@ -16,7 +16,6 @@ use ofborg::config;
use ofborg::checkout;
use ofborg::worker;
use ofborg::tasks;
use ofborg::nix;
fn main() {
@ -48,7 +47,7 @@ fn main() {
let mut channel = session.open_channel(2).unwrap();
let cloner = checkout::cached_cloner(Path::new(&cfg.checkout.root));
let nix = nix::new(cfg.nix.system.clone(), cfg.nix.remote.clone());
let nix = cfg.nix();
channel.basic_consume(
worker::new(tasks::build::BuildWorker::new(cloner, nix, cfg.nix.system.clone())),

View file

@ -10,7 +10,6 @@ use std::path::Path;
use ofborg::tasks;
use ofborg::config;
use ofborg::checkout;
use ofborg::nix;
use ofborg::worker;
use amqp::Session;
@ -46,7 +45,7 @@ fn main() {
let mut channel = session.open_channel(2).unwrap();
let cloner = checkout::cached_cloner(Path::new(&cfg.checkout.root));
let nix = nix::new(cfg.nix.system.clone(), cfg.nix.remote.clone());
let nix = cfg.nix();
let mrw = tasks::massrebuilder::MassRebuildWorker::new(

View file

@ -6,7 +6,7 @@ use hyper::Client;
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;
use hubcaps::{Credentials, Github};
use nix::Nix;
use ofborg::acl;
@ -32,6 +32,7 @@ pub struct RabbitMQConfig {
pub struct NixConfig {
pub system: String,
pub remote: String,
pub build_timeout_seconds: u16,
}
@ -76,6 +77,21 @@ impl Config {
Credentials::Token(self.github.clone().unwrap().token)
)
}
pub fn nix(&self) -> Nix {
if self.nix.build_timeout_seconds < 1200 {
error!("Note: {} is way too low for build_timeout_seconds!",
self.nix.build_timeout_seconds
);
error!("Please set build_timeout_seconds to at least 1200");
panic!();
}
return Nix::new(self.nix.system.clone(),
self.nix.remote.clone(),
self.nix.build_timeout_seconds
);
}
}

View file

@ -9,21 +9,24 @@ use std::io::SeekFrom;
#[derive(Clone, Debug, PartialEq)]
pub struct Nix {
system: String,
remote: String
}
pub fn new(system: String, remote: String) -> Nix {
return Nix{
system: system,
remote: remote,
}
remote: String,
build_timeout: u16
}
impl Nix {
pub fn new(system: String, remote: String, build_timeout: u16) -> Nix {
return Nix{
system: system,
remote: remote,
build_timeout: build_timeout,
}
}
pub fn with_system(&self, system: String) -> Nix {
return Nix{
system: system,
remote: self.remote.clone(),
build_timeout: self.build_timeout,
};
}
@ -58,6 +61,7 @@ impl Nix {
.env("NIX_PATH", nixpath)
.env("NIX_REMOTE", &self.remote)
.args(&["--option", "restrict-eval", "true"])
.args(&["--option", "build-timeout", &format!("{}", self.build_timeout)])
.args(&["--argstr", "system", &self.system])
.args(args)
.status()