File tree Expand file tree Collapse file tree 3 files changed +15
-14
lines changed Expand file tree Collapse file tree 3 files changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -90,5 +90,13 @@ def safely_prepend(module_name, opts = {})
90
90
opts [ :to ] . send ( :include , opts [ :from ] . const_get ( "Old" + module_name ) )
91
91
end
92
92
end
93
+
94
+ def sys_command ( unix_command , win_command = nil )
95
+ unix_result = `#{ unix_command } 2>&1` rescue nil # redirect stderr to stdout
96
+ return unix_result if unix_result != "" && unix_result
97
+ return if win_command . nil?
98
+ win_result = `#{ win_command } ` rescue nil
99
+ win_result != "" && win_result
100
+ end
93
101
end
94
102
end
Original file line number Diff line number Diff line change @@ -275,15 +275,15 @@ def detect_release
275
275
private
276
276
277
277
def detect_release_from_heroku
278
- sys_dyno_info = `cat /etc/heroku/dyno` rescue nil
279
- return unless sys_dyno_info && sys_dyno_info != ""
278
+ sys_dyno_info = File . read ( " /etc/heroku/dyno" ) . strip if File . directory? ( "/etc/heroku" ) rescue nil
279
+ return unless sys_dyno_info
280
280
281
281
# being overly cautious, because if we raise an error Raven won't start
282
282
begin
283
283
hash = JSON . parse ( sys_dyno_info )
284
284
hash && hash [ "release" ] && hash [ "release" ] [ "commit" ]
285
285
rescue JSON ::JSONError
286
- logger . error "Cannot parse Heroku JSON: #{ sys_dyno_info } "
286
+ Raven . logger . error "Cannot parse Heroku JSON: #{ sys_dyno_info } "
287
287
end
288
288
end
289
289
Original file line number Diff line number Diff line change @@ -24,10 +24,10 @@ def initialize
24
24
class << self
25
25
def os_context
26
26
@os_context ||= {
27
- "name" => sys_command ( "uname -s" ) || RbConfig ::CONFIG [ "host_os" ] ,
28
- "version" => sys_command ( "uname -v" ) ,
29
- "build" => sys_command ( "uname -r" ) ,
30
- "kernel_version" => sys_command ( "uname -a" , "ver" )
27
+ "name" => Raven . sys_command ( "uname -s" ) || RbConfig ::CONFIG [ "host_os" ] ,
28
+ "version" => Raven . sys_command ( "uname -v" ) ,
29
+ "build" => Raven . sys_command ( "uname -r" ) ,
30
+ "kernel_version" => Raven . sys_command ( "uname -a" , "ver" )
31
31
}
32
32
end
33
33
@@ -37,13 +37,6 @@ def runtime_context
37
37
"version" => RbConfig ::CONFIG [ "ruby_version" ]
38
38
}
39
39
end
40
-
41
- def sys_command ( unix_command , win_command = nil )
42
- unix_result = `#{ unix_command } ` rescue nil
43
- return unix_result if unix_result != "" && unix_result
44
- win_result = `#{ win_command } ` rescue nil
45
- win_result != "" && win_result
46
- end
47
40
end
48
41
end
49
42
end
You can’t perform that action at this time.
0 commit comments