gpt4 book ai didi

ruby-on-rails - Ubuntu: 'unicorn_init.sh start' 有效,但 'service unicorn_init start' 无效

转载 作者:行者123 更新时间:2023-12-04 18:38:22 24 4
gpt4 key购买 nike

我已经在 Ubuntu 12.04 服务器上安装了带有 unicorn 的 nginx。一切正常,站点,数据库, unicorn ......很好。所以我试图确保在重新启动后,nginx 和 unicorn 启动。我为我的 unicorn 进程设置了 update-rc.d,但它在重新启动后无法启动/工作。我怀疑这与 ubuntu 使用“服务”而不是“/etc/init.d/unicorn_init”有关
换句话说:
如果我执行:

$ /etc/init.d/unicorn_init start
unicorn 启动很好,没有错误。
如果我执行:
$ service unicorn_init start
它失败了, unicorn 没有启动。
我认为它与路径有关。我已将环境 PATHS 添加到 PATH、GEM_PATH 和 GEM_HOME,但我仍然收到相同的结果
1,如果我运行/usr/local/rvm/gems/ruby-1.9.3-p194/bin/unicorn,我会得到错误:
usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find unicorn (>= 0) amongst[bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/unicorn:18:in `<main>'
2,如果我运行/var/rails/web-app/bin/unicorn,我会得到错误:
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /var/rails/web-app/bin/unicorn:14:in `<main>'
任何帮助将不胜感激!谢谢

最佳答案

您应该使用包含所有必需环境变量的 unicorn 包装脚本:

rvm wrapper 1.9.3 ruby-1.9.3 unicorn

它将生成 ruby-1.9.3_unicorn在初始化脚本中使用它而不是只使用 unicorn 。

您可以通过以下方式找到有关包装器的更多详细信息:
rvm wrapper

如果通过捆绑器(如 capitrano)完成工作,则为 bundle 生成包装器:
rvm wrapper 1.9.3 ruby-1.9.3 bundle

并使用此命令显示的包装器的完整路径:
which ruby-1.9.3_bundle

关于ruby-on-rails - Ubuntu: 'unicorn_init.sh start' 有效,但 'service unicorn_init start' 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10454292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com