Gem 今天被这坑整惨了。。。

small_fish__ · 2014年03月04日 · 最后由 swordray 回复于 2014年03月07日 · 3239 次阅读

为啥会有这么奇葩的需求

#1 楼 @aptx4869 一台机器部署多个环境而已,这个需求不算奇葩吧。。。比如 staging , preproduction ...

RAILS_ENV=staging bundle exec unicorn_rails -E deployment 这种写法还不奇葩么……这和部队操练喊“向左向后转”有啥区别……

#3 楼 @aptx4869 -E 指的是 unicorn rack_env 代码地址:https://github.com/defunkt/unicorn/blob/master/bin/unicorn#L56。 根据文档上说,其实它只有 2 个环境,develpment 和 deployment。

RAILS_ENV 指的是 rails app env,它与用户自己定义有关系,显然 rails_env 会有多个任意环境。。所以,这里不应该覆盖 rails_env= rack_env...https://github.com/defunkt/unicorn/blob/master/bin/unicorn_rails#L57

根据文档上说,其实它只有2个环境, develpment 和deployment 没这种说法吧? 文档中写的明明是

-E, \--env RAILS_ENV
: Run under the given RAILS_ENV. This sets the RAILS_ENV environment
    variable. Acceptable values are exactly those you expect in your Rails
    application, typically "development" or "production".

我原来用 unicorn 的时候一直是unicorn_rails -E staging 啥事都没有,这种不看文档重复设置不同环境变量明明是自己坑自己……

#5 楼 @aptx4869 以前的版本是是没有这个问题,最新的版本有这个问题而已。。 关于 unicorn RACK_ENV 的文档在这里 http://unicorn.bogomips.org/unicorn_1.html#rack-environment

还有那些输出的命令只是 capistrano-unicorn 生成的而已,或许是因为我对应的版本没有对应好而已。。

亲,你看的是unicorn的文档,但上面用的明明是unicorn_rails... unicorn_rails 文档在那下面的 http://unicorn.bogomips.org/unicorn_rails_1.html 里面写着

-E, --env RAILS_ENV

    Run under the given RAILS_ENV. This sets the RAILS_ENV environment variable. Acceptable values are exactly those you expect in your Rails application, typically "development" or "production".

这是两个不同的命令……

#7 楼 @aptx4869 好的,我会再次检查一下的。好奇为啥根据配置文件出来就变成这样一个命令。。。

用 Puma 吧,多线程多进程

需要 登录 后方可回复, 如果你还没有账号请 注册新账号