File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ class Application < RuntimeError; end
2525 class Cron < RuntimeError ; end
2626 class Env < RuntimeError ; end
2727 class Exec < RuntimeError ; end
28+ class ErlCall < RuntimeError ; end
2829 class FileNotFound < RuntimeError ; end
2930 class Package < RuntimeError ; end
3031 class Service < RuntimeError ; end
Original file line number Diff line number Diff line change @@ -65,14 +65,31 @@ def action_run
6565 @new_resource . code . each_line { |line | stdin . puts ( line . chomp ) }
6666
6767 stdin . close
68-
69- Chef ::Log . info ( "Ran erl_call[#{ @new_resource . name } ] successfully" )
68+
7069 Chef ::Log . debug ( "erl_call[#{ @new_resource . name } ] output: " )
71-
72- stdout . each_line { |line | Chef ::Log . debug ( "#{ line } " ) }
73- stderr . each_line { |line | Chef ::Log . debug ( "#{ line } " ) }
70+
71+ stdout_output = ""
72+ stdout . each_line { |line |
73+ Chef ::Log . debug ( "#{ line } " )
74+ stdout_output << line
75+ }
7476 stdout . close
77+
78+ stderr_output = ""
79+ stderr . each_line { |line |
80+ Chef ::Log . debug ( "#{ line } " )
81+ stderr_output << line
82+ }
7583 stderr . close
84+
85+ if stdout_output . include? ( '{ok,' )
86+ Chef ::Log . info ( "Ran erl_call[#{ @new_resource . name } ] successfully" )
87+ elsif stderr_output . length > 0
88+ raise Chef ::Exceptions ::ErlCall , stderr_output
89+ else
90+ raise Chef ::Exceptions ::ErlCall , stdout_output
91+ end
92+
7693 ensure
7794 Process . wait ( pid ) if pid
7895 end
You can’t perform that action at this time.
0 commit comments