Can't start thin server as service, RubyGems: Could not find thin

*爱你&永不变心* 提交于 2019-12-03 08:17:37

It seems that each startup job is loaded its own shell. so, Try loading rvm before trying to start thin:

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

place this in /etc/init.d/thin_service & run

$ sudo update-rc.d  thin_service defaults

Lastly, you can test by by simply typing sudo start thin_service & sudo stop start_thin instead of rebooting. If this still doesn't work, try railsgems-bundler and rvm wrapper. Also, do read rvm's Deployment Best Practices

Since its seems from your stacktrace you are using rvm, and you are using thin installed as a gem, you need to use rvm wrappers for the service to work. First remove the service end re-install it rvmsudo thin install instead of sudo thin install. You should also use rvmsudo thin config while creating the configuration file as well.

To createa a wrapper,

rvm wrapper <your_rvm_ruby_version>@<your_rvm_gemset_in_use> bootup thin

you can find the names by using rvm list and rvm gemset list respectively. The wrapper will have name bootup_thin which you can confirm it is using the right rvm by which bootup_thin. You can give it whatever name you want while creating it. Then you need to edit thin script by

sudo nano /etc/init.d/thin

Change the original DAEMON to

DAEMON=location_of_bootup_thin 

Which should be the result of which bootup_thin. Then you can start the service.

sudo service thin start

I hope this helps

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