@@ -36,7 +36,7 @@ prior to `preconfigured.target` while `
[email protected] ` which is a requ
3636running "exec" commands are launched after preconfigured.target.
3737*/
3838
39- use log:: info;
39+ use log:: { info, warn } ;
4040use serde:: Deserialize ;
4141use simplelog:: { Config as LogConfig , LevelFilter , SimpleLogger } ;
4242use snafu:: { ensure, OptionExt , ResultExt } ;
@@ -100,11 +100,16 @@ where
100100{
101101 let mut command = Command :: new ( bin_path) ;
102102
103- command
103+ let output = command
104104 . args ( args)
105- . status ( )
105+ . output ( )
106106 . context ( error:: ExecutionFailureSnafu { command } ) ?;
107107
108+ ensure ! (
109+ output. status. success( ) ,
110+ error:: CommandFailureSnafu { bin_path, output }
111+ ) ;
112+
108113 Ok ( ( ) )
109114}
110115
@@ -198,10 +203,13 @@ fn run() -> Result<()> {
198203 for ( bootstrap_command_name, bootstrap_command) in bootstrap_commands. iter ( ) {
199204 let name = bootstrap_command_name. as_ref ( ) ;
200205 let essential = bootstrap_command. essential ;
201- let status = handle_bootstrap_command ( name, bootstrap_command) ;
206+ let result = handle_bootstrap_command ( name, bootstrap_command) ;
202207
208+ if let Err ( ref e) = result {
209+ warn ! ( "Bootstrap command failed to execute {}" , e) ;
210+ }
203211 ensure ! (
204- !essential || status . is_ok( ) ,
212+ !essential || result . is_ok( ) ,
205213 error:: BootstrapCommandExecutionSnafu { name }
206214 )
207215 }
@@ -221,7 +229,7 @@ fn main() {
221229mod error {
222230 use snafu:: Snafu ;
223231 use std:: path:: PathBuf ;
224- use std:: process:: Command ;
232+ use std:: process:: { Command , Output } ;
225233
226234 #[ derive( Debug , Snafu ) ]
227235 #[ snafu( visibility( pub ( super ) ) ) ]
@@ -247,6 +255,10 @@ mod error {
247255 source : std:: io:: Error ,
248256 } ,
249257
258+ #[ snafu( display( "'{}' failed - stderr: {}" ,
259+ bin_path, String :: from_utf8_lossy( & output. stderr) ) ) ]
260+ CommandFailure { bin_path : String , output : Output } ,
261+
250262 #[ snafu( display( "Logger setup error: {}" , source) ) ]
251263 Logger { source : log:: SetLoggerError } ,
252264
0 commit comments