无法启动瘦服务器作为服务,RubyGems:找不到瘦

我使用以下说明在Ubuntu 10.04.4上使用Rails 3.2.3在瘦服务器上安装和配置服务:

http://articles.slicehost.com/2008/5/6/ubuntu-hardy-thin-web-server-for-ruby

瘦服务器可以从应用程序根运行它,使用’thin start’

但是,当我尝试使用以下任何命令运行服务时:

service thin start sudo service thin start /etc/init.d/thin start sudo /etc/init.d/thin start 

我收到以下错误:

 /home/myuser/.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/myuser/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec' from /home/myuser/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem' from /home/myuser/.rvm/gems/ruby-1.9.3-p125/bin/thin:18:in `' 

这似乎不是PATH的问题,’瘦’正确返回:

 home/myuser/.rvm/gems/ruby-1.9.3-p125/bin/thin 

我已经validation了** / bin / thin的存在,只要它被引用

我尝试使用’gem uninstall thin’重新安装gem,’gem install thin’没有成功

有谁之前经历过这个吗? 我只发现了另一个此问题的实例: 无法通过远程计算机重新启动瘦身

这个问题似乎只是在ssh上,而我甚至无法在本地启动瘦服务

谢谢

似乎每个启动作业都加载了自己的shell。 所以,在尝试开始瘦之前尝试加载rvm

 #! /bin/sh # Load RVM into a shell session *as a function* if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then # First try to load from a user install source "$HOME/.rvm/scripts/rvm" elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then # Then try to load from a root install source "/usr/local/rvm/scripts/rvm" else printf "ERROR: An RVM installation was not found.\n" fi rvm use 1.9.3 cd /path/to/your/application/code bundle exec thin -d 

把它放在/etc/init.d/thin_service并运行

 $ sudo update-rc.d thin_service defaults 

最后,您可以通过简单地键入sudo start thin_servicesudo stop start_thin而不是重新启动来进行测试。 如果这仍然不起作用,请尝试使用railsgems-bundler和rvm包装器。 另外,请阅读rvm的部署最佳实践

由于它似乎来自你的堆栈跟踪,你正在使用rvm,并且你使用瘦作为gem安装,你需要使用rvm包装器来使服务工作。 首先删除服务端重新安装它rvmsudo thin install而不是sudo thin install 。 您还应该在创建配置文件时使用rvmsudo thin config

要创建一个包装器,

 rvm wrapper @ bootup thin 

你可以分别使用rvm listrvm gemset list找到这些名字。 包装器将具有名称bootup_thin ,您可以确认它正在使用正确的rvm bootup_thin 。 您可以在创建时为其提供任何名称。 然后你需要编辑瘦脚本

 sudo nano /etc/init.d/thin 

将原始DAEMON更改为

 DAEMON=location_of_bootup_thin 

哪个应该是which bootup_thin的结果。 然后你就可以开始服务了。

 sudo service thin start 

我希望这有帮助