From: Karim Hamidou Date: Thu, 23 Mar 2017 20:36:43 +0000 (-0700) Subject: Use the right version of minidump depending on the OS. X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=d1d8dc0f0ed940c5d7b613de8421a0275eba86f4;p=electron-breakpad-sentry.git Use the right version of minidump depending on the OS. --- diff --git a/Gemfile b/Gemfile index 861e1ff..9bee96d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,4 @@ source "http://rubygems.org/" gem "sinatra", "~> 1.4.7" gem "sentry_breakpad", "~> 0.1.10" +gem "os", "~> 1.0.0" diff --git a/Gemfile.lock b/Gemfile.lock index 8d3b538..bb6e4c2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,6 +4,7 @@ GEM faraday (0.11.0) multipart-post (>= 1.2, < 3) multipart-post (2.0.0) + os (1.0.0) rack (1.6.5) rack-protection (1.5.3) rack @@ -21,5 +22,6 @@ PLATFORMS ruby DEPENDENCIES + os (~> 1.0.0) sentry_breakpad (~> 0.1.10) sinatra (~> 1.4.7) diff --git a/app.rb b/app.rb index f01822f..ca519f8 100644 --- a/app.rb +++ b/app.rb @@ -1,5 +1,40 @@ +require 'os' require 'sinatra' +require 'sentry_breakpad' +require 'raven' + get '/' do - "Hello World!" + "heroku-breakpad-sentry is a simple breakpad server which forwards data to sentry. It's very easy to deploy to heroku." +end + + +post '/crashreport' do + unless params[:upload_file_minidump] and params[:upload_file_minidump][:filename] + halt 400, "Need to pass minidump upload" + end + + # Electron sends us crash reports in the minidump format. + # We need to read them and run minidump_stackwalk to be + # able to see them in an intelligible format. + file = params[:upload_file_minidump][:tempfile] + tmpfile = Tempfile.new('minidump') + + begin + tmpfile.write(file.read) + + res = '' + if OS.mac? + res = `./minidump_stackwalk_mac #{tmpfile.path}` + elsif OS.linux? and OS.bits == 64 + res = `./minidump_stackwalk_linux64 #{tmpfile.path}` + end + + SentryBreakpad.send_from_string(res) + ensure + tmpfile.close + tmpfile.unlink + end + + return 'ok' end diff --git a/minidump_stackwalk_linux64 b/minidump_stackwalk_linux64 new file mode 100644 index 0000000..2c447dc Binary files /dev/null and b/minidump_stackwalk_linux64 differ diff --git a/minidump_stackwalk_mac b/minidump_stackwalk_mac new file mode 100755 index 0000000..86cfa48 Binary files /dev/null and b/minidump_stackwalk_mac differ