我是否应该关注Heroku日志中出现的错误?

时间:2014-06-29 23:31:04

标签: ruby-on-rails heroku amazon-s3 carrierwave sidekiq

据我所知,我的截图#create动作在文本,开发和制作方面非常完美。然而,我的Heroku日志反复记录此错误的版本:

Jun 29 05:35:59 testivate app/web.1:  Started POST "/surveys/17480/screenshots" for 121.217.135.246 at 2014-06-29 12:35:58 +0000 
Jun 29 05:35:59 testivate app/web.1:  Processing by ScreenshotsController#create as HTML 
Jun 29 05:35:59 testivate app/web.1:    Parameters: {"utf8"=>"✓", "authenticity_token"=>"redacted", "screenshot"=>{"url"=>"http://tinyme.com.au", "result_ids"=>["38645", ""]}, "commit"=>"Create Screenshot", "survey_id"=>"17480"} 
Jun 29 05:35:59 testivate heroku/router:  at=info method=POST path="/surveys/17480/screenshots" host=www.testivate.com request_id=c11e0c7b-4b54-4e79-907c-46e0465b820f fwd="121.217.135.246" dyno=web.1 connect=2ms service=442ms status=302 bytes=563 
Jun 29 05:35:59 testivate app/web.1:  #<Heroku::API::Errors::Unauthorized: Expected(200) <=> Actual(401 Unauthorized) 
Jun 29 05:35:59 testivate app/web.1:  body: "{\"id\":\"unauthorized\",\"error\":\"Invalid credentials provided.\"}"> 

这是什么意思?

重要吗?

我该如何解决?

相关代码:

class ScreenshotsController < ApplicationController
  def create
    @survey = Survey.find(params[:survey_id])
    @review = @survey.review
    @competitor = @survey.competitor
    flash[:notice] = "Screenshot will be added" if @screenshot = @survey.screenshots.create(screenshot_params)
    ScreenshotGrabWorker.perform_async(@screenshot.id)    
    respond_with @survey, @screenshot
  end
  private
  def screenshot_params
    params.require(:screenshot).permit(:url, :shot, :crop_x, :crop_y, :crop_w, :crop_h, {result_ids: []}, :incbugs)
  end
end

class ScreenshotGrabWorker
  include Sidekiq::Worker
  def perform(id)
    if screenshot = Screenshot.find_by(:id => id)
      screenshot.copy_to_carrierwave
    end
  end
end

require 'cgi' unless defined?(CGI)
require 'digest' unless defined?(Digest)
class Screenshot < ActiveRecord::Base
  mount_uploader :shot, ShotUploader
  process_in_background :shot unless Rails.env.test?
  def copy_to_carrierwave
    self.remote_shot_url = get_url2png_url
    save!
  end
  def api_key
    ENV["URL2PNG_API_KEY"]
  end
  def private_key
    ENV["URL2PNG_PRIVATE_KEY"]
  end
  def s3_url
    url
  end
  def token
    Digest::MD5.hexdigest(query + private_key)
  end
  def store_url2png_url
    query_string = "http://api.url2png.com/v6/#{api_key}/#{token}/png/?#{query}"
    update_column :url2png_url, query_string
    return query_string
  end
  def get_url2png_url
    url2png_url.nil? ? store_url2png_url : url2png_url
  end
  def query(width=500, dimensions="1500x3000")
    current_time = Rails.env.test? ? Time.mktime(2020,1,1) : Time.now
    options = {
      url: url,
      viewport: dimensions,
      unique: current_time.to_i/60,
      filename: "screenshot_#{id}.png"}
    return options.map { |k,v| "#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}" }.join("&")
  end  
end

就像我说的,一切似乎都在起作用 - 包括在Heroku的制作中,我遇到了这些奇怪的错误。

0 个答案:

没有答案