added the crash dump routes

This commit is contained in:
Mike Slemmer 2013-07-31 19:06:21 -07:00
parent 248f9b3048
commit 234d9e29c3
3 changed files with 46 additions and 0 deletions

View File

@ -487,6 +487,46 @@ class ApiUsersController < ApiController
end
###################### CRASH DUMPS #######################
# This is very similar to api_music_sessions#perf_upload
# This should largely be moved into a library somewhere in jam-ruby.
def crash_dump
# example of using curl to access this API:
# curl -L -T some_file -X PUT http://localhost:3000/api/users/dump.json?client_type=[MACOSX/Win32/JamBox]&client_id=[CLIENT_ID]&session_id=[SESSION_ID]
# user_id is deduced if possible from the cookie.
@dump.client_type = params[:client_type]
@dump.client_id = params[:client_id]
@dump.user_id = current_user
@dump.session_id = params[:session_id]
unless @dump.save
# There are at least some conditions on valid dumps (need client_type)
response.status = :unprocessable_entity
respond_with @dump
return
end
# This part is the piece that really needs to be decomposed into a library...
if SampleApp::Application.config.storage_type == :fog
s3 = AWS::S3.new(:access_key_id => SampleApp::Application.config.aws_access_key_id,
:secret_access_key => SampleApp::Application.config.aws_secret_access_key)
# Fixme: Should we use the same bucket for everything?
bucket = s3.buckets[SampleApp::Application.config.aws_bucket]
url = bucket.objects[@dump.uri].url_for(:write, :expires => SampleApp::Application.config.crash_dump_data_signed_url_timeout, :'response_content_type' => 'application/octet-stream').to_s
logger.debug("crash_dump can upload to url #{url}")
redirect_to url
else
# we should store it here to aid in development, but we don't have to until someone wants the feature
# so... just return 200
render :json => { :id => @dump.id }, :status => 200
end
end
###################### RECORDINGS #######################
# def recording_index
# @recordings = User.recording_index(current_user, params[:id])

View File

@ -133,6 +133,9 @@ if defined?(Bundler)
#config.perf_data_bucket_key = "perf_data"
config.perf_data_signed_url_timeout = 3600 * 24 # 1 day
# crash_dump configs
config.crash_dump_data_signed_url_timeout = 3600 * 24 # 1 day
# client update killswitch; turn on if client updates are broken and are affecting users
config.check_for_client_updates = true
end

View File

@ -248,5 +248,8 @@ SampleApp::Application.routes.draw do
# list all uris for available clients on mac, windows, linux, if available
match '/artifacts/clients' => 'artifacts#client_downloads'
# crash logs
match '/dumps' => 'api_users#crash_dump', :via => :put
end
end