Skip to content

Commit

Permalink
try to capture validation output and print out in case of failure to …
Browse files Browse the repository at this point in the history
…validate
  • Loading branch information
craigcomstock committed Oct 14, 2024
1 parent 8f96ca0 commit b453e1e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/service_config.cf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ bundle agent service_config(service_name,config_template_path,config_final_path,

bundle agent validate_config_and_restart_service(staged_config,validate_config_command,config_final_path,service_name)
{
vars:
"validation_output" string => "$(staged_config)-validation.log";
classes:

"config_validated" expression => returnszero("$(validate_config_command) $(staged_config)", "useshell");
"config_validated" expression => returnszero("$(validate_config_command) $(staged_config) 2>&1 >$(validation_output)", "useshell");
"config_final_exists" expression => fileexists("$(config_final_path)");
"staged_config_newer" expression => isnewerthan("$(staged_config)", "$(config_final_path)");

Expand Down Expand Up @@ -58,4 +60,5 @@ bundle agent validate_config_and_restart_service(staged_config,validate_config_c
"$(staged_config) validates" if => "config_validated";
"$(config_final_path) exists" if => "config_final_exists";
"$(staged_config) is newer than $(config_final_path)" if => "staged_config_newer";
"validation output ${with}" with => readfile("${validation_output}");
}

0 comments on commit b453e1e

Please sign in to comment.