【问题标题】:Cannot restart thin via remote machine无法通过远程机器重新启动瘦
【发布时间】:2023-03-15 05:03:01
【问题描述】:

我使用 Thin 为位于测试机器上的 rails 应用程序提供服务。我希望能够从我的本地机器停止/开始瘦,但以下不起作用:

ssh luc@test_machine '/home/luc/.rvm/gems/ruby-1.9.3-p125/bin/thin -v'

我收到以下错误消息:

/home/luc/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find thin (>= 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 /home/luc/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /home/luc/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems.rb:1230:in `gem'
from /home/luc/.rvm/gems/ruby-1.9.3-p125/bin/thin:18:in `<main>'

为什么我有分数时它只列出 6 颗宝石?

当我通过 ssh 连接到测试服务器时:

which thin

给了我正确的道路:

/home/luc/.rvm/gems/ruby-1.9.3-p125/bin/thin  (question updated with correct path)

更新

我在服务器上创建了一个基本的 test.sh 脚本:

#!/bin/bash
# Update path with ruby / gem
export PATH=$PATH:/home/luc/.rvm/rubies/ruby-1.9.3-p125/bin:/home/luc/.rvm/gems/ruby-1.9.3-p125/bin/
thin -v
exit 0

我从本地机器调用它

ssh luc@test_machine '/home/luc/test.sh'

但仍然是相同的“找不到薄”错误。

更新 2

这可能与脚本通过 ssh 运行时使用的 rubies / gemset 相关联。我已经添加了

rvm list
rvm gemset list

在 test.sh 文件中,我的输出是:

rvm rubies

* ruby-1.9.3-p125 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

gemsets for system (found in /home/luc/.rvm/gems/system)
*

似乎我安装的 gem 不存在...虽然不知道指定 rubies/gemset 版本以通过 ssh 调用使用。

【问题讨论】:

  • 你没有使用which thin 给你的路径。尝试将 '/home/luc/.rvm/gems/ruby-1.9.3-p125/bin/thin -v' 更改为 '/home/gp/.rvm/gems/ruby-1.9.3-p125/bin/thin '

标签: ruby-on-rails ruby ssh rubygems thin


【解决方案1】:

你使用捆绑器吗?

试试看

bundle exec thin -v

如果这不起作用或您不使用捆绑程序,请通过键入检查 $PATH 变量

echo PATH

如果宝石不在路径中,他将无法加载它,我敢打赌它是带有路径的东西 :) 更新它们并摇滚

在最坏的情况下,您将不得不生成 rvm gem 包装器,有关更多信息,请阅读此

http://beginrescueend.com/integration/god/

干杯!

【讨论】:

  • 谢谢,我已经用关于 PATH 的附加信息更新了这个问题。我很确定这也与路径有关,但尚无法弄清楚此错误的原因。
【解决方案2】:

我用另一种方式来管理它。我没有尝试从远程机器重新启动服务器,而是安装了 gem "rerun" (https://github.com/alexch/rerun),因此当某些代码发生更改时,瘦服务器的重新启动会自动完成。

rerun -- thin start

这个技巧真的很好

【讨论】:

    【解决方案3】:

    这个解决方案对我有用(远程和 capistrano!)

    看看这个answer

    只需放置:

    source "/usr/local/rvm/scripts/rvm" # or ~/.rvm/..
    rvm use 1.9.3
    

    在 /etc/init.d/thin

    或为capistrano

    %w[start stop restart].each do |command|
      desc "#{command} thin server"
      task command, roles: :app do
        run "source '/usr/local/rvm/scripts/rvm' && rvm use 1.9.3 && service thin #{command}"
      end
      after "deploy:#{command}", "thin:#{command}"
    end
    

    如果您为每个用户安装了 rvm,请将源路径更改为 '~/.rvm/scripts/rvm'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-16
      • 2013-08-30
      • 1970-01-01
      • 2012-11-11
      相关资源
      最近更新 更多