在部署到heroku之后,我很难让亚马逊Web服务S3存储成为我的活动记录存储解决方案,而不是在生产环境中使用本地存储。我在heroku日志中收到内部服务器错误,这根本没有帮助。
我的storage.yml
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
amazon:
service: S3
access_key_id: "won't show you"
secret_access_key: "won't show"
region: "us-east-2"
bucket: "novay-technologies"
production.rb
config.active_storage.service = :amazon
也制作了procfile,因为我需要在Heroku上的生产环境中将Puma用于Web服务器。不知道我是否做对了。据我了解,这是一个纯文本文件,没有文件扩展名(如.txt),并且应该位于应用程序的根目录中。
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-production}
宝石文件:
gem "aws-sdk-s3", require: false
我做错了什么吗?我还在heroku应用程序上为aws_secret凭据,存储桶名称等配置了变量。
Heroku日志:
$ heroku logs --tail
2018-09-14T05:33:47.732692+00:00 app[web.1]: I, [2018-09-14T05:33:47.732579 #12] INFO -- : [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] Processing by HomeBlogsController#index as HTML
2018-09-14T05:33:47.756797+00:00 app[web.1]: I, [2018-09-14T05:33:47.756647 #12] INFO -- : [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] Rendering home_blogs/index.html.erb within layouts/application
2018-09-14T05:33:47.770155+00:00 app[web.1]: I, [2018-09-14T05:33:47.770028 #12] INFO -- : [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] Rendered home_blogs/_team_slider.html.erb (2.0ms)
2018-09-14T05:33:47.771796+00:00 app[web.1]: I, [2018-09-14T05:33:47.771700 #12] INFO -- : [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] Rendered home_blogs/index.html.erb within layouts/application (14.8ms)
2018-09-14T05:33:47.772226+00:00 app[web.1]: I, [2018-09-14T05:33:47.772143 #12] INFO -- : [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] Completed 500 Internal Server Error in 39ms
2018-09-14T05:33:47.773372+00:00 app[web.1]: F, [2018-09-14T05:33:47.773284 #12] FATAL -- : [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d]
2018-09-14T05:33:47.773494+00:00 app[web.1]: F, [2018-09-14T05:33:47.773397 #12] FATAL -- : [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] ActionView::Template::Error (The asset "DanielProfile.jpeg" is not present in the asset pipeline.):
2018-09-14T05:33:47.773954+00:00 app[web.1]: F, [2018-09-14T05:33:47.773873 #12] FATAL -- : [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] 4: <div id="team-slider">
2018-09-14T05:33:47.773957+00:00 app[web.1]: [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] 5:
2018-09-14T05:33:47.773959+00:00 app[web.1]: [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] 6: <div class="person active" id="person1">
2018-09-14T05:33:47.773960+00:00 app[web.1]: [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] 7: <%= image_tag "DanielProfile.jpeg", :id=>"daniel-pic"%>
2018-09-14T05:33:47.773962+00:00 app[web.1]: [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] 8: <figcaption><b>Daniel</b></figcaption><p id="bio-text">Info 1</p><br />
2018-09-14T05:33:47.773964+00:00 app[web.1]: [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] 9: </div>
2018-09-14T05:33:47.773966+00:00 app[web.1]: [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] 10: <div class="person" id="person2">
2018-09-14T05:33:47.773987+00:00 app[web.1]: F, [2018-09-14T05:33:47.773932 #12] FATAL -- : [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d]
2018-09-14T05:33:47.774080+00:00 app[web.1]: F, [2018-09-14T05:33:47.774022 #12] FATAL -- : [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] app/views/home_blogs/_team_slider.html.erb:7:in `_app_views_home_blogs__team_slider_html_erb__3603015324260213397_47229290931480'
2018-09-14T05:33:47.774083+00:00 app[web.1]: [ff92f910-5fc0-4fcf-895f-d1b3b78b8f2d] app/views/home_blogs/index.html.erb:48:in `_app_views_home_blogs_index_html_erb___3304137320579381618_47229290790300'
2018-09-14T05:33:48.937228+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=boiling-chamber-89366.herokuapp.com request_id=5801439c-e276-4837-b2d3-9a071b985f88 fwd="107.77.210.166" dyno=web.1 connect=1ms service=13ms status=304 bytes=48 protocol=https
2018-09-14T05:42:45.000000+00:00 app[api]: Build started by user davidmichaelberko@gmail.com
2018-09-14T05:43:36.124158+00:00 heroku[web.1]: Restarting
2018-09-14T05:43:36.125133+00:00 heroku[web.1]: State changed from up to starting
2018-09-14T05:43:37.184709+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-09-14T05:43:37.215584+00:00 app[web.1]: [4] - Gracefully shutting down workers...
2018-09-14T05:43:37.667388+00:00 heroku[web.1]: Process exited with status 143
2018-09-14T05:43:35.147502+00:00 app[api]: Deploy b0e39bae by user davidmichaelberko@gmail.com
2018-09-14T05:43:35.147502+00:00 app[api]: Release v30 created by user davidmichaelberko@gmail.com
2018-09-14T05:43:44.000000+00:00 app[api]: Build succeeded
2018-09-14T05:43:48.420966+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2018-09-14T05:43:52.242466+00:00 app[web.1]: [4] Puma starting in cluster mode...
2018-09-14T05:43:52.242489+00:00 app[web.1]: [4] * Version 3.12.0 (ruby 2.3.5-p376), codename: Llamas in Pajamas
2018-09-14T05:43:52.242491+00:00 app[web.1]: [4] * Min threads: 5, max threads: 5
2018-09-14T05:43:52.242492+00:00 app[web.1]: [4] * Environment: production
2018-09-14T05:43:52.242494+00:00 app[web.1]: [4] * Process workers: 2
2018-09-14T05:43:52.242498+00:00 app[web.1]: [4] * Preloading application
2018-09-14T05:44:03.889732+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:42357
2018-09-14T05:44:03.890105+00:00 app[web.1]: [4] ! WARNING: Detected 1 Thread(s) started in app boot:
2018-09-14T05:44:03.890264+00:00 app[web.1]: [4] ! #<Thread:0x00005645c567a6e0@/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:297 sleep> - /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:299:in `sleep'
2018-09-14T05:44:03.890454+00:00 app[web.1]: [4] Use Ctrl-C to stop
2018-09-14T05:44:03.937869+00:00 app[web.1]: [4] - Worker 0 (pid: 8) booted, phase: 0
2018-09-14T05:44:03.961444+00:00 app[web.1]: [4] - Worker 1 (pid: 10) booted, phase: 0
2018-09-14T05:44:04.216217+00:00 heroku[web.1]: State changed from starting to up
2018-09-14T05:44:05.299286+00:00 app[web.1]: I, [2018-09-14T05:44:05.299069 #8] INFO -- : [b6f95d3c-9886-456d-8be6-a2c3182228df] Started GET "/" for 107.77.210.166 at 2018-09-14 05:44:05 +0000
2018-09-14T05:44:05.310460+00:00 app[web.1]: I, [2018-09-14T05:44:05.310361 #8] INFO -- : [b6f95d3c-9886-456d-8be6-a2c3182228df] Processing by HomeBlogsController#index as HTML
2018-09-14T05:44:05.339011+00:00 app[web.1]: I, [2018-09-14T05:44:05.338894 #8] INFO -- : [b6f95d3c-9886-456d-8be6-a2c3182228df] Rendering home_blogs/index.html.erb within layouts/application
2018-09-14T05:44:05.351987+00:00 app[web.1]: I, [2018-09-14T05:44:05.351887 #8] INFO -- : [b6f95d3c-9886-456d-8be6-a2c3182228df] Rendered home_blogs/_team_slider.html.erb (1.9ms)
2018-09-14T05:44:05.352439+00:00 app[web.1]: I, [2018-09-14T05:44:05.352370 #8] INFO -- : [b6f95d3c-9886-456d-8be6-a2c3182228df] Rendered home_blogs/index.html.erb within layouts/application (13.2ms)
2018-09-14T05:44:05.353290+00:00 app[web.1]: I, [2018-09-14T05:44:05.353183 #8] INFO -- : [b6f95d3c-9886-456d-8be6-a2c3182228df] Completed 500 Internal Server Error in 40ms
2018-09-14T05:44:05.355779+00:00 app[web.1]: F, [2018-09-14T05:44:05.355705 #8] FATAL -- : [b6f95d3c-9886-456d-8be6-a2c3182228df]
2018-09-14T05:44:05.355917+00:00 app[web.1]: F, [2018-09-14T05:44:05.355854 #8] FATAL -- : [b6f95d3c-9886-456d-8be6-a2c3182228df] ActionView::Template::Error (The asset "DanielProfile.jpeg" is not present in the asset pipeline.):
2018-09-14T05:44:05.356321+00:00 app[web.1]: F, [2018-09-14T05:44:05.356268 #8] FATAL -- : [b6f95d3c-9886-456d-8be6-a2c3182228df] 4: <div id="team-slider">
2018-09-14T05:44:05.356338+00:00 app[web.1]: [b6f95d3c-9886-456d-8be6-a2c3182228df] 5:
2018-09-14T05:44:05.356340+00:00 app[web.1]: [b6f95d3c-9886-456d-8be6-a2c3182228df] 6: <div class="person active" id="person1">
2018-09-14T05:44:05.356342+00:00 app[web.1]: [b6f95d3c-9886-456d-8be6-a2c3182228df] 7: <%= image_tag "DanielProfile.jpeg", :id=>"daniel-pic"%>
2018-09-14T05:44:05.356343+00:00 app[web.1]: [b6f95d3c-9886-456d-8be6-a2c3182228df] 8: <figcaption><b>Daniel</b></figcaption><p id="bio-text">Info 1</p><br />
2018-09-14T05:44:05.356345+00:00 app[web.1]: [b6f95d3c-9886-456d-8be6-a2c3182228df] 9: </div>
2018-09-14T05:44:05.356346+00:00 app[web.1]: [b6f95d3c-9886-456d-8be6-a2c3182228df] 10: <div class="person" id="person2">
2018-09-14T05:44:05.356602+00:00 app[web.1]: F, [2018-09-14T05:44:05.356549 #8] FATAL -- : [b6f95d3c-9886-456d-8be6-a2c3182228df]
2018-09-14T05:44:05.356712+00:00 app[web.1]: [b6f95d3c-9886-456d-8be6-a2c3182228df] app/views/home_blogs/index.html.erb:48:in `_app_views_home_blogs_index_html_erb___3107958943898777696_47428845125780'
2018-09-14T05:44:05.356710+00:00 app[web.1]: F, [2018-09-14T05:44:05.356640 #8] FATAL -- : [b6f95d3c-9886-456d-8be6-a2c3182228df] app/views/home_blogs/_team_slider.html.erb:7:in `_app_views_home_blogs__team_slider_html_erb___1927171972031439227_47428845168680'
2018-09-14T05:44:05.358493+00:00 heroku[router]: at=info method=GET path="/" host=boiling-chamber-89366.herokuapp.com request_id=b6f95d3c-9886-456d-8be6-a2c3182228df fwd="107.77.210.166" dyno=web.1 connect=0ms service=65ms status=500 bytes=1827 protocol=https
2018-09-14T05:44:06.613224+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=boiling-chamber-89366.herokuapp.com request_id=e5ed5731-f771-4ab7-afbf-3e7f2d86d85c fwd="107.77.210.166" dyno=web.1 connect=0ms service=5ms status=200 bytes=143 protocol=https
2018-09-14T05:45:04.903443+00:00 heroku[web.1]: Restarting
2018-09-14T05:45:04.905478+00:00 heroku[web.1]: State changed from up to starting
2018-09-14T05:45:06.313295+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-09-14T05:45:06.335333+00:00 app[web.1]: [4] - Gracefully shutting down workers...
2018-09-14T05:45:07.214828+00:00 heroku[web.1]: Process exited with status 143
2018-09-14T05:45:17.193313+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2018-09-14T05:45:20.580532+00:00 app[web.1]: [4] Puma starting in cluster mode...
2018-09-14T05:45:20.580563+00:00 app[web.1]: [4] * Version 3.12.0 (ruby 2.3.5-p376), codename: Llamas in Pajamas
2018-09-14T05:45:20.580564+00:00 app[web.1]: [4] * Min threads: 5, max threads: 5
2018-09-14T05:45:20.580566+00:00 app[web.1]: [4] * Environment: production
2018-09-14T05:45:20.580567+00:00 app[web.1]: [4] * Process workers: 2
2018-09-14T05:45:20.580569+00:00 app[web.1]: [4] * Preloading application
2018-09-14T05:45:32.131340+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:53222
2018-09-14T05:45:32.131751+00:00 app[web.1]: [4] ! WARNING: Detected 1 Thread(s) started in app boot:
2018-09-14T05:45:32.131894+00:00 app[web.1]: [4] ! #<Thread:0x0000556669fe6350@/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:297 sleep> - /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:299:in `sleep'
2018-09-14T05:45:32.132083+00:00 app[web.1]: [4] Use Ctrl-C to stop
2018-09-14T05:45:32.154305+00:00 app[web.1]: [4] - Worker 1 (pid: 10) booted, phase: 0
2018-09-14T05:45:32.157217+00:00 app[web.1]: [4] - Worker 0 (pid: 8) booted, phase: 0
2018-09-14T05:45:32.833157+00:00 heroku[web.1]: State changed from starting to up
2018-09-14T05:45:35.047364+00:00 app[web.1]: I, [2018-09-14T05:45:35.047164 #8] INFO -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad] Started GET "/" for 107.77.210.166 at 2018-09-14 05:45:35 +0000
2018-09-14T05:45:35.060284+00:00 app[web.1]: I, [2018-09-14T05:45:35.060154 #8] INFO -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad] Processing by HomeBlogsController#index as HTML
2018-09-14T05:45:35.088955+00:00 app[web.1]: I, [2018-09-14T05:45:35.088816 #8] INFO -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad] Rendering home_blogs/index.html.erb within layouts/application
2018-09-14T05:45:35.101253+00:00 app[web.1]: I, [2018-09-14T05:45:35.101109 #8] INFO -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad] Rendered home_blogs/_team_slider.html.erb (2.7ms)
2018-09-14T05:45:35.101556+00:00 app[web.1]: I, [2018-09-14T05:45:35.101475 #8] INFO -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad] Rendered home_blogs/index.html.erb within layouts/application (12.3ms)
2018-09-14T05:45:35.102302+00:00 app[web.1]: I, [2018-09-14T05:45:35.102231 #8] INFO -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad] Completed 500 Internal Server Error in 41ms
2018-09-14T05:45:35.104595+00:00 app[web.1]: F, [2018-09-14T05:45:35.104479 #8] FATAL -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad]
2018-09-14T05:45:35.104745+00:00 app[web.1]: F, [2018-09-14T05:45:35.104653 #8] FATAL -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad] ActionView::Template::Error (The asset "DanielProfile.jpeg" is not present in the asset pipeline.):
2018-09-14T05:45:35.105338+00:00 app[web.1]: F, [2018-09-14T05:45:35.105220 #8] FATAL -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad] 4: <div id="team-slider">
2018-09-14T05:45:35.105341+00:00 app[web.1]: [3e50fd37-83b8-4d42-a369-6b03c7d87cad] 5:
2018-09-14T05:45:35.105343+00:00 app[web.1]: [3e50fd37-83b8-4d42-a369-6b03c7d87cad] 6: <div class="person active" id="person1">
2018-09-14T05:45:35.105347+00:00 app[web.1]: [3e50fd37-83b8-4d42-a369-6b03c7d87cad] 7: <%= image_tag "DanielProfile.jpeg", :id=>"daniel-pic"%>
2018-09-14T05:45:35.105349+00:00 app[web.1]: [3e50fd37-83b8-4d42-a369-6b03c7d87cad] 8: <figcaption><b>Daniel</b></figcaption><p id="bio-text">Info 1</p><br />
2018-09-14T05:45:35.105352+00:00 app[web.1]: [3e50fd37-83b8-4d42-a369-6b03c7d87cad] 9: </div>
2018-09-14T05:45:35.105354+00:00 app[web.1]: [3e50fd37-83b8-4d42-a369-6b03c7d87cad] 10: <div class="person" id="person2">
2018-09-14T05:45:35.105462+00:00 app[web.1]: F, [2018-09-14T05:45:35.105380 #8] FATAL -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad]
2018-09-14T05:45:35.105578+00:00 app[web.1]: F, [2018-09-14T05:45:35.105512 #8] FATAL -- : [3e50fd37-83b8-4d42-a369-6b03c7d87cad] app/views/home_blogs/_team_slider.html.erb:7:in `_app_views_home_blogs__team_slider_html_erb___49138702036072628_46949189469860'
2018-09-14T05:45:35.105582+00:00 app[web.1]: [3e50fd37-83b8-4d42-a369-6b03c7d87cad] app/views/home_blogs/index.html.erb:48:in `_app_views_home_blogs_index_html_erb__3183323660226002528_46949189328600'
2018-09-14T05:45:35.110118+00:00 heroku[router]: at=info method=GET path="/" host=boiling-chamber-89366.herokuapp.com request_id=3e50fd37-83b8-4d42-a369-6b03c7d87cad fwd="107.77.210.166" dyno=web.1 connect=0ms service=67ms status=500 bytes=1827 protocol=https
2018-09-14T05:45:35.913068+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=boiling-chamber-89366.herokuapp.com request_id=cdfbccd2-efcf-4a1a-8c9e-849d05efa8fd fwd="107.77.210.166" dyno=web.1 connect=0ms service=1ms status=304 bytes=48 protocol=https
▸ Log stream timed out. Please try again.
puma.rb
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.3.5'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.0'
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'jquery-rails'
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
gem 'devise'
gem 'acts_as_votable', '~> 0.11.1'
gem 'bootstrap', '~> 4.1.1'
gem 'simple_form'
gem 'tinymce-rails-imageupload', github: 'PerfectlyNormal/tinymce-rails-imageupload'
gem 'will_paginate'
gem 'carrierwave'
gem 'mini_magick'
gem 'fog'
gem 'foundation-rails'
gem 'autoprefixer-rails'
gem 'pg'
gem "aws-sdk-s3", require: false
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15', '< 4.0'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]