6

我正在尝试使用supervisord管理一个 ruby​​ 脚本,但是因为我还没有完全理解 RVM 是如何工作的,所以我无法正确地完成它。

通常我会做以下事情:

# sourcing of rvm done automatically on ssh login
cd /var/rails/myapp
RAILS_ENV="production" bundle exec ./script/backgroundrb

但是使用以下配置文件我无法做到:

[program:owgm]
directory=/var/rails/owgm
command=bundle exec ./script/backgroundrb
environment=RAILS_ENV="production"
PATH="/usr/local/rvm/gems/ree-1.8.7-2012.02@global/bin/bundle:$PATH"
autostart=true
autorestart=true

我收到以下错误:

无法加载 OpenSSL。您必须使用 OpenSSL 支持重新编译 Ruby,或将 Gemfile 中的源代码从“https”更改为“http”。rvm.io/packages/openssl 提供了使用 RVM 使用 OpenSSL 进行编译的说明。

看起来我无法获得正确的 ruby​​ 环境。

我认为设置路径会起作用,因为如果我这样做:

which bundle

我得到:/usr/local/rvm/gems/ree-1.8.7-2012.02@global/bin/bundle

但我什至不确定发生了什么。

使用 Python,我会执行以下操作:

command=/path/to/virtualenv/bin/python /path/to/script.py

我可以用红宝石做类似的事情吗?

rvm info的输出是:

ree-1.8.7-2012.02:

  system:
    uname:       "Linux owtb2 3.2.0-44-generic #69-Ubuntu SMP Thu May 16 17:35:01 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux"
    system:      "ubuntu/12.04/x86_64"
    bash:        "/bin/bash => GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.21.3 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "4 months 4 days 3 hours 54 minutes 35 seconds ago"

  ruby:
    interpreter:  "ruby"
    version:      "1.8.7"
    date:         "2012-02-08"
    platform:     "x86_64-linux"
    patchlevel:   "2012-02-08 MBARI 8/0x6770 on patchlevel 358"
    full_version: "ruby 1.8.7 (2012-02-08 MBARI 8/0x6770 on patchlevel 358) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2012.02"

  homes:
    gem:          "/usr/local/rvm/gems/ree-1.8.7-2012.02"
    ruby:         "/usr/local/rvm/rubies/ree-1.8.7-2012.02"

  binaries:
    ruby:         "/usr/local/rvm/rubies/ree-1.8.7-2012.02/bin/ruby"
    irb:          "/usr/local/rvm/rubies/ree-1.8.7-2012.02/bin/irb"
    gem:          "/usr/local/rvm/rubies/ree-1.8.7-2012.02/bin/gem"
    rake:         "/usr/local/rvm/gems/ree-1.8.7-2012.02@global/bin/rake"

  environment:
    PATH:         "/usr/local/rvm/gems/ree-1.8.7-2012.02/bin:/usr/local/rvm/gems/ree-1.8.7-2012.02@global/bin:/usr/local/rvm/rubies/ree-1.8.7-2012.02/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
    GEM_HOME:     "/usr/local/rvm/gems/ree-1.8.7-2012.02"
    GEM_PATH:     "/usr/local/rvm/gems/ree-1.8.7-2012.02:/usr/local/rvm/gems/ree-1.8.7-2012.02@global"
    MY_RUBY_HOME: "/usr/local/rvm/rubies/ree-1.8.7-2012.02"
    IRBRC:        "/usr/local/rvm/rubies/ree-1.8.7-2012.02/.irbrc"
    RUBYOPT:      ""
    gemset:       ""
4

2 回答 2

7

感谢@mpapis 的建议,我已经能够找出一些可行的方法。

不幸的是,他的建议没有,但他是对的,因为我必须查看/usr/local/rvm/wrappers

这是工作配置文件:

[program:owgm]
directory=/var/rails/owgm
command=/usr/local/rvm/wrappers/ree-1.8.7-2012.02/bundle exec ./script/backgroundrb
environment=RAILS_ENV="production"
autostart=true
autorestart=true
于 2013-11-06T13:53:43.250 回答
3

它应该是:

PATH="/usr/local/rvm/wrappers/ree-1.8.7-2012.02@global:$PATH"
于 2013-11-06T12:27:15.390 回答