Cannot restart thin via remote machine

浪尽此生 提交于 2019-12-12 01:45:12

问题


I use Thin to serve the rails application located on a test machine. I'd like to be able to stop/start thin from my local machine but the following does not work:

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

I got the following error message:

/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>'

Why does it list only 6 gems when I have scores ?

When I'm connected in ssh onto the test server:

which thin

gives me the right path:

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

UPDATE

I have created a basic test.sh script on the server:

#!/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

I call it from my local machine

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

But still the same "could not find thin" error.

UPDATE 2

This might be linked to the rubies / gemset used when the script is run through ssh. I have added

rvm list
rvm gemset list

in the test.sh file and the output I have is:

rvm rubies

* ruby-1.9.3-p125 [ x86_64 ]

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

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

It seems that the gems I have installed are not there... Don't know to spefify the rubies/gemset version to use through a ssh call though.


回答1:


Do you use bundler ?

Try doing

bundle exec thin -v

If this will not work or you don't use bundler, check $PATH variable by typing

echo PATH

if gems are not in path he will not be able to load it, i bet it is something with paths :) Update them and rock'n'roll

In worst case you will have to generate rvm gem wrappers, for more info read this

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

Cheers!




回答2:


I managed this using another way. Instead of trying to restart the server from a remote machine, I installed the gem "rerun" (https://github.com/alexch/rerun) so the restart of the thin server is done automatically when some code is changed.

rerun -- thin start

does the trick really well




回答3:


this solutions worked for me ( remote & capistrano ! )

look at this answer !

just place:

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

in /etc/init.d/thin

or for 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

if you installed rvm per user change source path to '~/.rvm/scripts/rvm'



来源:https://stackoverflow.com/questions/10314138/cannot-restart-thin-via-remote-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!