这是我的第一个问题,所以我希望我在规则内。我的Rails教程(第7章)与彪马Heroku部署不断崩溃
我刚刚完成了Michale Hartl Rails教程的第7章。我的sample_app在本地工作,并在此之前一直在Heroku上工作。
本章最后是一个名为“7.5专业级部署”的部分。这将生产环境切换到SSL和Puma Web服务器。
以下代码显示了我作为本节的一部分所做的更改,导致应用程序无法在Heroku上运行。
配置/环境/ production.rb - 未注释这条线,以使SSL
config.force_ssl = true
的Gemfile - 加入彪马
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma', '2.11.1'
end
配置/ puma.rb - 我复制这个直接从Heroku网站复制完Rails Tutorial pdf后失败
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['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
创造了Procfile
web: bundle exec puma -C config/puma.rb
提交之后,力推的Heroku和迁移数据库,我得到一个网页,上面写着 “应用程序错误”。
这是Heroku的日志输出:
2015-05-14T11:55:46.257652+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2015-05-14T11:55:48.438024+00:00 app[web.1]: ... ^
2015-05-14T11:55:48.438026+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `_load_from'
2015-05-14T11:55:48.438029+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/configuration.rb:40:in `load'
2015-05-14T11:55:48.438035+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/bin/puma:10:in `<top (required)>'
2015-05-14T11:55:48.438034+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/cli.rb:453:in `run'
2015-05-14T11:55:48.438017+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `instance_eval': config/puma.rb:1: syntax error, unexpected tIDENTIFIER, expecting end-of-input (SyntaxError)
2015-05-14T11:55:48.438040+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/bin/puma:23:in `<main>'
2015-05-14T11:55:48.438031+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/cli.rb:308:in `parse_options'
2015-05-14T11:55:48.438039+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/bin/puma:23:in `load'
2015-05-14T11:55:48.437914+00:00 app[web.1]: config/puma.rb:1: warning: encountered \r in middle of line, treated as a mere space
threads_count = Integer(ENV['MAX_THREADS']......NCURRENCY'] || 2)
2015-05-14T11:55:49.211862+00:00 heroku[web.1]: Process exited with status 1
2015-05-14T11:55:49.223366+00:00 heroku[web.1]: State changed from starting to crashed
我从“语法错误”有什么东西不对我的配置/ puma.rb文件,但我不能工作了的印象什么。
我试过指定Ruby版本号,但是没有帮助。
这是怎么回事,我该怎么说才对?
可能是从网站复制文本到编辑器添加一些额外的空格的问题,如http://stackoverflow.com/questions/18946105/rails-4-syntax-error-unexpected-tidentifier-expecting-end-of -input尝试从头开始输入'config/puma.rb'的内容。 –
谢谢,我重新输入了所有的空格和换行符,因为我以前遇到过这个问题。但我想我现在会尝试重新输入整个文档。 (我最近开始使用Atom,到目前为止还没有像这样的问题。) –
尝试重新打字,没有工作:( –