[英]Environment variable in unicorn script
I want to configure the worker processes depending on the environment. 我想根据环境配置工作进程。 But how should I use the condition in unicorn script wrt environment variabes.
但是我应该如何在环境变量的独角兽脚本中使用条件。
I have used following code but does not work - 我使用了以下代码,但不起作用-
if ENV['RAILS_ENV'] == "development" worker = 1 elsif ENV['RAILS_ENV'] == "staging" || ENV['RAILS_ENV'] == "testing" worker = 2 else worker = 16 end worker_processes worker
If you see the code to define the Rails.env : 如果您看到定义Rails.env的代码:
# File railties/lib/rails.rb, line 81
def env
@_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
end
Return "development" if ENV["RAILS_ENV"] and ENV["RACK_ENV"] are blank. 如果ENV [“ RAILS_ENV”]和ENV [“ RACK_ENV”]为空,则返回“开发”。
So you must use the Rails.env in your script or change it. 因此,您必须在脚本中使用Rails.env或对其进行更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.