Heroku 500错误,使用Heroku,Rails

时间:2014-06-22 23:37:09

标签: ruby-on-rails heroku

我正在尝试使用回形针将图像上传到S3。它目前在开发中非常有效,但是当我将它推送到heroku时,我获得了500的状态。

我查看了当前的主题,其中一些原因是缺少pg gem和未配置的存储桶名称,但我已经检查了这些。

我的错误日志目前说明了这个

2014-06-22T23:13:44.118505+00:00 app[web.1]: I, [2014-06-22T23:13:44.118013 #2]  INFO -- : Command :: convert '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' -auto-orient -resize "x100" -crop "100x100+99+0" +repage -set colorspace sRGB -strip '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-10cae74.jpg'
2014-06-22T23:13:44.040021+00:00 app[web.1]: I, [2014-06-22T23:13:31.758844 #2]  INFO -- :   Rendered patients/new.html.erb within layouts/application (2.6ms)
2014-06-22T23:13:44.040023+00:00 app[web.1]: I, [2014-06-22T23:13:31.759625 #2]  INFO -- : Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
2014-06-22T23:13:44.040024+00:00 app[web.1]: I, [2014-06-22T23:13:44.027440 #2]  INFO -- : Started POST "/patients" for 107.19.177.84 at 2014-06-22 23:13:44 +0000
2014-06-22T23:13:44.040026+00:00 app[web.1]: I, [2014-06-22T23:13:44.031624 #2]  INFO -- : Processing by PatientsController#create as HTML
2014-06-22T23:13:44.081130+00:00 app[web.1]: I, [2014-06-22T23:13:44.080608 #2]  INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' 2>/dev/null
2014-06-22T23:13:44.040028+00:00 app[web.1]: I, [2014-06-22T23:13:44.031790 #2]  INFO -- :   Parameters: {"utf8"=>"✓", "authenticity_token"=>"6LvlNWsTg6qCoILIbt1pjvUX1mvP+WbnHUX4yYVPHdI=", "patient"=>{"name"=>"Yitao Zhang", "number"=>"6503916966", "email"=>"yitaoz@stanford.edu", "appointment"=>"2014-06-16", "avatar"=>#<ActionDispatch::Http::UploadedFile:0x007f7324f6e7f0 @tempfile=#<Tempfile:/tmp/RackMultipart20140622-2-1gopf5s>, @original_filename="images.jpeg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"patient[avatar]\"; filename=\"images.jpeg\"\r\nContent-Type: image/jpeg\r\n">, "description"=>"adsafasdf"}, "commit"=>"Submit"}
2014-06-22T23:13:44.184102+00:00 app[web.1]: I, [2014-06-22T23:13:44.183584 #2]  INFO -- : Command :: file -b --mime '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-10cae74.jpg'
2014-06-22T23:13:44.040030+00:00 app[web.1]: I, [2014-06-22T23:13:44.038575 #2]  INFO -- : Command :: file -b --mime-type '/tmp/8f2ed61a3cb4149d8c9abca38721647720140622-2-1c1dac6'
2014-06-22T23:13:44.260870+00:00 app[web.1]: I, [2014-06-22T23:13:44.260288 #2]  INFO -- : Command :: convert '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' -auto-orient -resize "x480" -crop "480x480+478+0" +repage -set colorspace sRGB -strip '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-ye2lmv.jpg'
2014-06-22T23:13:44.470900+00:00 app[web.1]: I, [2014-06-22T23:13:44.470357 #2]  INFO -- : Command :: file -b --mime '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-ye2lmv.jpg'
2014-06-22T23:13:44.544510+00:00 app[web.1]: I, [2014-06-22T23:13:44.543987 #2]  INFO -- : Command :: convert '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' -auto-orient -resize "600>" -set colorspace sRGB -strip '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-1rbg2jr.jpg'
2014-06-22T23:13:44.621867+00:00 app[web.1]: I, [2014-06-22T23:13:44.621332 #2]  INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' 2>/dev/null
2014-06-22T23:13:44.590252+00:00 app[web.1]: I, [2014-06-22T23:13:44.589723 #2]  INFO -- : Command :: file -b --mime '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-1rbg2jr.jpg'
2014-06-22T23:13:44.506015+00:00 app[web.1]: I, [2014-06-22T23:13:44.505469 #2]  INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' 2>/dev/null
2014-06-22T23:13:44.662154+00:00 app[web.1]: I, [2014-06-22T23:13:44.661637 #2]  INFO -- : Command :: convert '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' -auto-orient -resize "1200>" -set colorspace sRGB -strip -sharpen 0x0.5 '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-fpzvpn.jpg'
2014-06-22T23:13:44.743824+00:00 app[web.1]: I, [2014-06-22T23:13:44.743315 #2]  INFO -- : Command :: file -b --mime '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-fpzvpn.jpg'
2014-06-22T23:13:44.836262+00:00 heroku[router]: at=info method=POST path="/patients" host=glacial-scrubland-2600.herokuapp.com request_id=47cf63e3-59f9-4dc0-be18-fc06ae702775 fwd="107.19.177.84" dyno=web.1 connect=1ms service=1078ms status=500 bytes=1543
2014-06-22T23:13:44.790408+00:00 app[web.1]: I, [2014-06-22T23:13:44.789786 #2]  INFO -- : Command :: file -b --mime-type '/tmp/47f9c6187d138877e010f0255fe25ac920140622-2-1fmy0hr'

我唯一的提示是状态= 500。

非常感谢任何想法/帮助!

1 个答案:

答案 0 :(得分:0)

ENV Vars

最相关的问题可能是您没有正确设置ENV个变量。这些是 environment 特定的 - 这意味着你必须在每个&#34;环境中设置它们。 (服务器)您将应用部署到

许多人常见的问题是,他们将部署到Heroku而不设置这些ENV变量,从而阻止系统访问所需的信息。

解决方案是使用heroku config:set VARIABLE=value in your CMD

-

<强>生产

您的日志没有任何错误,这不是非常有用

因此,另外一个猜测是你没有在Rails中设置production environment options

#config/environments/production.rb
config.paperclip_defaults = {
  :storage => :s3,
  :s3_credentials => {
    :bucket => ENV['S3_BUCKET_NAME'],
    :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
    :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
  }
}

可能还有另一个问题,即paperclip使用bucket选项的方式。我们发现它需要此设置才能正常工作:

#config/environments/production.rb
config.paperclip.defaults = {
    storage: :s3,
    s3_host_name: 's3-eu-west-1.amazonaws.com',
    s3_credentials: {
      access_key_id: ENV['AWS_ACCESS_KEY_ID'],
      secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
    },
    bucket: ENV['S3_BUCKET_NAME']
}