Skip to content

Commit

Permalink
use hab-sup from a package
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Parfitt committed May 21, 2016
1 parent c46a95f commit a94687f
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion components/director/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ use std::io::prelude::*;
use std::net::SocketAddrV4;
use std::path::PathBuf;
use std::process::{Command, Stdio, Child};
use std::str::FromStr;
use std::thread;

use libc::{pid_t, c_int};
use time::{Duration, SteadyTime};



use error::Result;
use hcore;
use hcore::package::PackageIdent;
use hsup::package::Package;
use hsup::supervisor::{WEXITSTATUS, WIFEXITED, WIFSIGNALED, WTERMSIG, Pid};
use hsup::util::signals;
use super::ServiceDef;
Expand Down Expand Up @@ -49,9 +54,27 @@ impl ExecContext {
}
}


impl Default for ExecContext {
/// use the latest hab-sup and the default Hab service root
/// Fall back to HAB_SUP_PATH if we can't find it.
/// Run hab-director with `RUST_LOG=habitat_director=debug`
/// to see the start params including hab-sup path
fn default() -> ExecContext {
ExecContext::new(PathBuf::from(HAB_SUP_PATH), hcore::fs::svc_root())
if let Ok(ident) = PackageIdent::from_str("core/hab-sup") {
if let Ok(pkg) = Package::load(&ident, None) {
let mut hab_director = pkg.path().to_path_buf();
hab_director.push("bin");
hab_director.push("hab-sup");
ExecContext::new(hab_director, hcore::fs::svc_root())
} else {
println!("Can't find core/hab-sup, falling back to {}", &HAB_SUP_PATH);
ExecContext::new(PathBuf::from(HAB_SUP_PATH), hcore::fs::svc_root())
}
} else {
println!("Can't find core/hab-sup, falling back to {}", &HAB_SUP_PATH);
ExecContext::new(PathBuf::from(HAB_SUP_PATH), hcore::fs::svc_root())
}
}
}

Expand Down

0 comments on commit a94687f

Please sign in to comment.