2015-01-13 1 views
0
def convert_vend_types_param 
    if params[:schedule_machine][:vend_types].present? 
     vend_types = [] 
     params[:schedule_machine][:vend_types].each_pair do |vt, active| 
     vend_types << vt.to_sym if active.to_i > 0 
     end 
     params[:schedule_machine][:vend_types] = vend_types 
    end 
    end 

api :PUT, "/v1/schedules/:schedule_id/schedule_machines/:id", "Update a schedule machine" 
    param_group :schedule_machine 
    error :code => 422 
    def update 
    convert_vend_types_param 

    if params[:schedule_machine] 
     if params[:schedule_machine][:products_returned_at] 
     new_date = params[:schedule_machine][:products_returned_at] 
     if @schedule_machine.products_returned_at == nil || new_date.to_date > @schedule_machine.products_returned_at.to_date 
      ScheduleMachineProductCounterJob.new.async.perform(@schedule_machine.id) 
     end 
     end 
    end 

    unless @schedule_machine.update_attributes(params[:schedule_machine]) 
     render(json: { error: 'Invalid schedule machine information' }, status: :unprocessable_entity) and return 
    end 

    render :show 
    end 

내 요청 및 타임 아웃 :이 간단한 PUT 요청이 시간 초과되는 이유는 무엇입니까?

2015-01-13T17:52:06.437358+00:00 app[web.1]: Parameters: {"token"=>"mytoken", "schedule_machine"=>{"remove_verified_at"=>"2015-01-13"}, "schedule_id"=>"58", "schedule_location_id"=>"2178", "id"=>"4874"} 
2015-01-13T17:52:06.437292+00:00 app[web.1]: Processing by Api::V1::ScheduleMachinesController#update as JSON 
2015-01-13T17:52:07.441605+00:00 app[web.1]: Rendered api/v1/schedule_machines/show.json.rabl (740.3ms) 
2015-01-13T17:52:10.681136+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=PUT path="/api/v1/schedules/58/schedule_locations/2178/schedule_machines/4874.json" host=myapp.herokuapp.com request_id=1e4ea64a-8552-4e5d-8580-3c2a8d04ec49 fwd="107.77.72.114" dyno=web.1 connect=2ms service=30001ms status=503 bytes=0 

답변

0

에게 Heroku는 요청에 대한 30 년대의 하드 제한이 있습니다. 귀하의 요청은 (서비스 = 30001ms) 살해되어이 방법의 단계 중 하나가 문제가되었습니다.

데이터베이스 시간 초과 (교착 상태가 발생했거나 이상한 다른 이유로 인해)가 발생했거나 비동기 작업이 예상대로 빠르게 반환되지 않는 것 같습니다.

NewRelic 또는 Skylight를 사용중인 경우 요청 내용을 자세히 들여다 보면 의 진행 상황을 볼 수 있습니다. 콘솔에서 명령을 실행할 수도 있습니다.

+0

이 경우 비동기 작업이 발생하지 않아야합니다. 모델 속성을 업데이트하는 중입니다. – quantumpotato

+0

트리거 할 수있는 콜백이 있습니까? –

관련 문제