'production' 环境 (Puma) 缺少 'secret_token' 和 'secret_key_base'

Missing 'secret_token' and 'secret_key_base' for 'production' environment (Puma)

我不明白为什么我的 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'

请帮忙!

通过查看您的配置文件,答案似乎很明显。

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