Add BUILDER_RUNNER_DEBUG env var to builder-worker
If this env var is set, the studio that the runner executes will have
it's debug output enabled
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
+
pub mod log_pipe;
pub mod workspace;
pub mod postprocessor;
-pub use protocol::jobsrv::JobState;
-
use std::ffi::OsString;
use std::fs;
use std::ops::{Deref, DerefMut};
@@ -26,9 +25,10 @@ use std::str::FromStr;
use std::sync::{mpsc, Arc, RwLock};
use std::thread::{self, JoinHandle};
+pub use protocol::jobsrv::JobState;
use chrono::UTC;
use depot_client;
-use hab_core::{self, crypto};
+use hab_core::{self, crypto, env};
use hab_core::package::archive::PackageArchive;
use hab_core::package::install::PackageInstall;
use hab_core::package::PackageIdent;
@@ -47,6 +47,8 @@ use config::Config;
use error::{Error, Result};
use vcs;
+/// Environment variable to enable or disable debug output in runner's studio
+const RUNNER_DEBUG_ENV: &'static str = "BUILDER_RUNNER_DEBUG";
/// In-memory zmq address of Job RunnerMgr
const INPROC_ADDR: &'static str = "inproc://runner";
/// Protocol message to indicate the Job Runner has received a work request
@@ -246,16 +248,29 @@ impl Runner {
.unwrap())];
let command = studio_cmd();
debug!("building, cmd={:?}, args={:?}", command, args);
- let mut child = Command::new(command)
+ let mut child = match env::var(RUNNER_DEBUG_ENV) {
+ Ok(val) => {
+ Command::new(command)
+ .args(&args)
+ .env_clear()
+ .env("HAB_NONINTERACTIVE", "true")
+ .env("DEBUG", val)
+ .stdout(Stdio::piped())
+ .stderr(Stdio::piped())
+ .spawn()
+ .expect("failed to spawn child")
+ }
+ Err(_) => {
+ Command::new(command)
.args(&args)
.env_clear()
- // This disables download progress bars; otherwise we have
- // to filter out loads of carriage returns!
.env("HAB_NONINTERACTIVE", "true")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
- .expect("failed to spawn child");
+ .expect("failed to spawn child")
+ }
+ };
self.log_pipe().pipe(&mut child);
let exit_status = child.wait().expect("failed to wait on child");
debug!("build complete, status={:?}", exit_status);
@@ -302,11 +317,25 @@ impl Runner {
let command = studio_cmd();
debug!("removing studio, cmd={:?}, args={:?}", command, args);
- let mut child = Command::new(command)
+ let mut child = match env::var(RUNNER_DEBUG_ENV) {
+ Ok(val) => {
+ Command::new(command)
.args(&args)
.env_clear()
+ .env("HAB_NONINTERACTIVE", "true")
+ .env("DEBUG", val)
.spawn()
- .expect("failed to spawn child");
+ .expect("failed to spawn child")
+ }
+ Err(_) => {
+ Command::new(command)
+ .args(&args)
+ .env_clear()
+ .env("HAB_NONINTERACTIVE", "true")
+ .spawn()
+ .expect("failed to spawn child")
+ }
+ };
let exit_status = child.wait().expect("failed to wait on child");
debug!("studio removal complete, status={:?}", exit_status);
if exit_status.success() {
