缺少' secret_token'和' secret_key_base'为了生产'环境(美洲狮)

时间:2016-04-05 09:27:10

标签: ruby-on-rails ruby puma secret-key

我不明白为什么我的secret_token和secret_key_base不会被Puma阅读。该应用程序正在通过Capistrano,Nginx和Puma进行部署。

secrets.yml

development:
  secret_key_base: XXXXXXXXXXXXXXXXXX
  secret_token: XXXXXXXXXXX

test:
  secret_key_base: XXXXXXXXXXXXXXXXXXXXXXXXXXXX

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
  secret_token: <%= ENV["SECRET_TOKEN"] %>

我的.gitignore文件不是阻止我的secrets.yml文件,但每当我尝试连接到我的服务器时,我都会被告知An unhandled lowlevel error occurred. The application logs may have details.

我的应用程序日志告诉我,我是Missing 'secret_token' and 'secret_key_base' for 'production' environment

完整的申请日志

=== puma startup: 2016-04-05 07:00:04 -0400 ===
2016-04-05 07:00:09 -0400: Rack app error: #<RuntimeError: Missing     `secret_token` and `secret_key_base` for 'production' environment, set these values in `config/secrets.yml`>
/home/deploy/apps/IASAS_site/shared/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:534:in `validate_secret_key_config!'
/home/deploy/apps/IASAS_site/shared/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:246:in `env_config'
/home/deploy/apps/IASAS_site/shared/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:514:in `call'
/home/deploy/apps/IASAS_site/shared/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:165:in `call'
/home/deploy/apps/IASAS_site/shared/bundle/ruby/2.2.0/gems/puma-3.2.0/lib/puma/configuration.rb:227:in `call'
/home/deploy/apps/IASAS_site/shared/bundle/ruby/2.2.0/gems/puma-3.2.0/lib/puma/server.rb:561:in `handle_request'
/home/deploy/apps/IASAS_site/shared/bundle/ruby/2.2.0/gems/puma-3.2.0/lib/puma/server.rb:406:in `process_client'
/home/deploy/apps/IASAS_site/shared/bundle/ruby/2.2.0/gems/puma-3.2.0/lib/puma/server.rb:271:in `block in run'
/home/deploy/apps/IASAS_site/shared/bundle/ruby/2.2.0/gems/puma-3.2.0/lib/puma/thread_pool.rb:111:in `call'
/home/deploy/apps/IASAS_site/shared/bundle/ruby/2.2.0/gems/puma-3.2.0/lib/puma/thread_pool.rb:111:in `block in spawn_thread'

请帮忙!

1 个答案:

答案 0 :(得分:0)

通过查看配置文件,答案似乎非常明显。

在生产中,Puma从两个环境变量( SECRET_KEY_BASE SECRET_TOKEN )中获取这些值。您需要在生产服务器上定义这些环境变量。