Skip to content

Commit d70f56c

Browse files
committed
Heroku detection works on /etc/dyno, also fix backtick commands elsewhere
1 parent 739383d commit d70f56c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/raven/configuration.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,24 @@ def project_root=(root_dir)
267267
end
268268

269269
def detect_release
270-
detect_release_from_heroku ||
270+
detect_release_from_git ||
271271
detect_release_from_capistrano ||
272-
detect_release_from_git
272+
detect_release_from_heroku
273273
end
274274

275275
private
276276

277277
def detect_release_from_heroku
278-
ENV['HEROKU_SLUG_COMMIT']
278+
sys_dyno_info = `cat /etc/heroku/dyno` rescue nil
279+
return unless sys_dyno_info && sys_dyno_info != ""
280+
281+
# being overly cautious, because if we raise an error Raven won't start
282+
begin
283+
hash = JSON.parse(sys_dyno_info)
284+
hash && hash["release"] && hash["release"]["commit"]
285+
rescue JSON::JSONError
286+
logger.error "Cannot parse Heroku JSON: #{sys_dyno_info}"
287+
end
279288
end
280289

281290
def detect_release_from_capistrano

0 commit comments

Comments
 (0)