[英]Rails Unicorn Web Server Won't Start on Heroku
我无法让我的应用程序成功启动Heroku。 这是基础知识:
我已将我的应用程序部署到Heroku,但收到“应用程序中发生错误,无法提供您的页面”。
这是Heroku日志中的最终条目:
+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
+00:00 heroku[web.1]: Process exited with status 1
+00:00 heroku[web.1]: State changed from starting to crashed
当我尝试运行Heroku ps时,我得到:
=== web (1X): `bundle exec unicorn -p $PORT -c ./config/unicorn.rb`
web.1: crashed 2013/06/22 17:31:22 (~ 6m ago)
我认为问题可能源于我的app / config / application.rb中的这一行
ENV.update YAML.load(File.read(File.expand_path('../application.yml', __FILE__)))
这行在dev中用于从我的application.yml文件中读取我的环境变量。 但是,为了安全起见,我从我的仓库中获取它,并且可以看到Heroku日志抱怨此文件未找到。 为了生产,我通过以下方式在Heroku中设置了我的环境变量:
heroku config:add SECRET_TOKEN=a_really_long_number
这是我的app / 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
这是我的Procfile
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
我的app / config / unicorn.rb和Procfile设置都来自https://devcenter.heroku.com/articles/rails-unicorn
根据一些IRC指导,我安装了费加罗,但唉,但没有解决问题。
如果你想看到完整的应用程序,它发布在: https : //github.com/mxstrand/mxspro
如果您对可能出现的问题有所了解或者我可能会如何进一步排除故障,我会很感激。 谢谢。
你随时可以看到你的分析。 我刚刚提取了你的代码,做了一些调整,现在已经开始在Heroku上了。
我唯一的变化;
config/application.rb
- 将第12和13行移动到config/environments/development.rb
- 如果您正在将application.yml用于开发环境变量,那么请保持这种方式。 其他选择是使用if Rails.env.development?
使第13行以您的开发环境为if Rails.env.development?
在末尾。
config/environments/production.rb
- 在#mark之前缺少第33行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.