简体   繁体   English

独角兽脚本中的环境变量

[英]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.

相关问题 Unicorn init脚本 - 不在启动时启动 - Unicorn init script - not starting at boot Unicorn.rb配置取决于环境 - Unicorn.rb configuration depending on environment 使用RVM配置独角兽服务脚本 - Configure unicorn service script using RVM Capistrano-Unicorn宝石环境设置错误 - Capistrano-unicorn gem getting wrong environment set Rails +独角兽+ Nginx + Capistrano 3 + Linode VPS:无法识别暂存环境 - Rails + Unicorn + Nginx + Capistrano 3 + Linode VPS: Not Recognizing Staging Environment Unicorn Deploy to Heroku的问题-仅生产环境问题 - Issue with Unicorn Deploy to Heroku - production environment issues only 如何在Capistrano部署脚本中使用Rails环境变量? - How to use a Rails environment variable in Capistrano deploy script? Unicorn服务upstart脚本抛出“-su:bundle:command not found” - Unicorn service upstart script throws “-su: bundle: command not found” 缓存:[GET /] miss? dalli gem,memcached,rails 3.1,nginx,unicorn生产环境 - cache: [GET /] miss? dalli gem, memcached, rails 3.1, nginx, unicorn production environment 如果我想要更快的速度,设置Nginx / Unicorn / Rails本地开发环境是否不好/毫无意义? - Is it bad/pointless to setup a Nginx/Unicorn/Rails local dev environment if I want faster speed?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM