我已经完成了一个rails 4示例项目,它在本地运行完美,但在我将应用程序推送到Heroku之后,它没有按预期工作。
细节:
An error occurred in the application and your page could not be served. Please try again in a few moments.
我检查了heroku logs
,没有iead。但根据日志,我想这是与独角兽有关的事情。任何人都可以帮忙吗?我将非常感激!
Databse.yml文件
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: devep00
test:
<<: *default
database: testp00
heroku日志:
Snailwalkers-MacBook-Pro:sample_app snailwalker$ heroku logs
2014-09-07T19:32:54+00:00 heroku[slug-compiler]: Slug compilation started
2014-09-07T19:33:56.565867+00:00 heroku[api]: Scale to web=1 by leevn2011@hotmail.com
2014-09-07T19:33:57.132548+00:00 heroku[api]: Set DATABASE_URL config vars by leevn2011@hotmail.com
2014-09-07T19:33:57.132641+00:00 heroku[api]: Release v3 created by leevn2011@hotmail.com
2014-09-07T19:33:57.243793+00:00 heroku[api]: Attach HEROKU_POSTGRESQL_GREEN resource by leevn2011@hotmail.com
2014-09-07T19:33:57.243851+00:00 heroku[api]: Release v4 created by leevn2011@hotmail.com
2014-09-07T19:33:57.393814+00:00 heroku[api]: Set LANG, RAILS_ENV, RACK_ENV config vars by leevn2011@hotmail.com
2014-09-07T19:33:57.393877+00:00 heroku[api]: Release v5 created by leevn2011@hotmail.com
2014-09-07T19:33:57+00:00 heroku[slug-compiler]: Slug compilation finished
2014-09-07T19:33:57.539396+00:00 heroku[api]: Deploy e80716a by leevn2011@hotmail.com
2014-09-07T19:33:57.539450+00:00 heroku[api]: Release v6 created by leevn2011@hotmail.com
2014-09-07T19:34:01.271365+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 59399 -c ./config/unicorn.rb`
2014-09-07T19:34:02.533517+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:75:in `reload'
2014-09-07T19:34:02.533522+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:100:in `new'
2014-09-07T19:34:02.533531+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
2014-09-07T19:34:02.533527+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `new'
2014-09-07T19:34:02.533493+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:75:in `read': No such file or directory - ./config/unicorn.rb (Errno::ENOENT)
2014-09-07T19:34:02.533529+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
2014-09-07T19:34:02.533520+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:68:in `initialize'
2014-09-07T19:34:02.533524+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:100:in `initialize'
2014-09-07T19:34:02.533533+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
2014-09-07T19:34:03.231638+00:00 heroku[web.1]: Process exited with status 1
2014-09-07T19:34:03.244168+00:00 heroku[web.1]: State changed from starting to crashed
2014-09-07T19:34:03.244899+00:00 heroku[web.1]: State changed from crashed to starting
2014-09-07T19:34:06.618532+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 52599 -c ./config/unicorn.rb`
2014-09-07T19:34:08.894160+00:00 heroku[web.1]: State changed from starting to crashed
2014-09-07T19:34:08.881607+00:00 heroku[web.1]: Process exited with status 1
2014-09-07T19:34:10.316575+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=floating-citadel-1018.herokuapp.com request_id=1e8ef6e8-d75a-4ab4-8226-55145a4467fc fwd="54.234.54.24" dyno= connect= service= status=503 bytes=
2014-09-07T19:34:10.736054+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by leevn2011@hotmail.com
2014-09-07T19:34:14.730812+00:00 heroku[run.1558]: Awaiting client
2014-09-07T19:34:15.007129+00:00 heroku[run.1558]: State changed from starting to up
2014-09-07T19:34:15.417252+00:00 heroku[run.1558]: Starting process with command `bundle exec rake db:migrate`
2014-09-07T19:34:19.586495+00:00 heroku[run.1558]: Process exited with status 0
2014-09-07T19:34:29.658637+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=floating-citadel-1018.herokuapp.com request_id=1887e778-55ba-49cf-bdfb-0ce17242a766 fwd="223.207.119.11" dyno= connect= service= status=503 bytes=
2014-09-07T20:19:19.632175+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 22985 -c ./config/unicorn.rb`
2014-09-07T20:19:20.900907+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:75:in `read': No such file or directory - ./config/unicorn.rb (Errno::ENOENT)
2014-09-07T20:19:20.900931+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:75:in `reload'
2014-09-07T20:19:20.900944+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
2014-09-07T20:19:20.900939+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:100:in `initialize'
2014-09-07T20:19:20.900942+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `new'
2014-09-07T20:19:20.900934+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:68:in `initialize'
2014-09-07T20:19:20.900937+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:100:in `new'
2014-09-07T20:19:20.900946+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
2014-09-07T20:19:20.900948+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
2014-09-07T20:19:21.498680+00:00 heroku[web.1]: Process exited with status 1
2014-09-07T20:19:21.510352+00:00 heroku[web.1]: State changed from starting to crashed
2014-09-07T21:15:01.753637+00:00 heroku[web.1]: State changed from crashed to starting
2014-09-07T21:15:06.155014+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 49088 -c ./config/unicorn.rb`
2014-09-07T21:15:07.548375+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:75:in `reload'
2014-09-07T21:15:07.548382+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `new'
2014-09-07T21:15:07.548377+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:68:in `initialize'
2014-09-07T21:15:07.548379+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:100:in `new'
2014-09-07T21:15:07.548386+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
2014-09-07T21:15:07.548388+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
2014-09-07T21:15:07.548380+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:100:in `initialize'
2014-09-07T21:15:07.548359+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:75:in `read': No such file or directory - ./config/unicorn.rb (Errno::ENOENT)
2014-09-07T21:15:07.548389+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
2014-09-07T21:15:08.482550+00:00 heroku[web.1]: Process exited with status 1
2014-09-07T21:15:08.491156+00:00 heroku[web.1]: State changed from starting to crashed
2014-09-07T22:43:45.803188+00:
00 heroku[web.1]: State changed from crashed to starting
2014-09-07T22:43:50.156498+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 19812 -c ./config/unicorn.rb`
2014-09-07T22:43:52.812859+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:75:in `read': No such file or directory - ./config/unicorn.rb (Errno::ENOENT)
2014-09-07T22:43:52.812878+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:75:in `reload'
2014-09-07T22:43:52.812880+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/configurator.rb:68:in `initialize'
2014-09-07T22:43:52.812882+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:100:in `new'
2014-09-07T22:43:52.812884+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:100:in `initialize'
2014-09-07T22:43:52.812887+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
2014-09-07T22:43:52.812885+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `new'
2014-09-07T22:43:52.812889+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
2014-09-07T22:43:52.812890+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
2014-09-07T22:43:53.423053+00:00 heroku[web.1]: State changed from starting to crashed
2014-09-07T22:43:53.413503+00:00 heroku[web.1]: Process exited with status 1
2014-09-08T02:26:33.345491+00:00 heroku[web.1]: State changed from crashed to starting
2014-09-08T02:26:35.654836+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 16954 -c ./config/unicorn.rb`
2014-09-08T02:26:37.200528+00:00 heroku[web.1]: Process exited with status 1
2014-09-08T02:26:37.212486+00:00 heroku[web.1]: State changed from starting to crashed
2014-09-08T05:52:44.822578+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=floating-citadel-1018.herokuapp.com request_id=a974d050-855e-446e-9b86-c82406868111 fwd="223.205.148.195" dyno= connect= service= status=503 bytes=
的Gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.2'
gem 'bootstrap-sass', '2.3.2.0'
gem 'bcrypt-ruby'
gem 'pg', '0.15.1'
gem 'unicorn'
group :development, :test do
gem 'guard-spork', :github => 'guard/guard-spork'
gem 'sprockets', '2.11.0'
gem 'rspec-rails', '2.13.1'
gem 'guard-rspec', '2.5.0'
gem 'spork-rails', '4.0.0'
gem 'childprocess', '0.3.6'
end
group :test do
gem 'factory_girl_rails', '4.2.1'
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.3'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '2.2.1'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'rails_12factor', group: :production
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
procfile:
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
答案 0 :(得分:1)
您需要拥有Unicorn的配置文件,请创建包含以下内容的文件并将其放入config/unicorn.rb
# config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
这里有更多细节 https://devcenter.heroku.com/articles/rails-unicorn#config
答案 1 :(得分:0)
正如@charinten所指出的那样 - 在你的unicorn.rb文件中将其发布在config下,如果你还没有这个(在我发布之后看到答案)
worker_processes 4
timeout 30
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end