Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am attempting to create a start-up script that will run this command on boot for my ubuntu 12.04 server:

bundle exec thin -R config.ru start -p 3030

When I run it as a regular user it works just fine, the thin web server starts and I can access my page that I need. Below is the start up script I am trying to use /etc/init/thin.conf:

description "thin"
version "1.0"
author "Me"

env LANG=en_US.UTF-8
env APP_HOME=/home/username/onlinetraining_dashboard
respawn
start on runlevel [23]
script
cd $APP_HOME
sudo -u username /home/username/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle exec thin -R config.ru start -p 3030 > $APP_HOME/log/thin.log 2>&1
end script

I will then type "sudo start thin" to run the script and it should start on boot.

When I start the service I get this error in the log file:

/usr/bin/env: ruby_executable_hooks: No such file or directory

I am using ruby with RVM 1.9.3.

Here is my .bash_profile that I am assuming lets me run the command bundle exec thin -R config.ru start -p 3030 without errors:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

I also tried this without success in the script.

sudo -u username bundle exec thin -R config.ru start -p 3030 > $APP_HOME/log/thin.log 2>&1

Thanks for the help.

share|improve this question

1 Answer 1

you should use wrappers, you can read more about them here: http://rvm.io/integration/init-d

share|improve this answer
    
Welcome to server fault! While a link might include information perfect for answering the question, as links change, it's preferred to give at least a summary. –  Falcon Momot Jan 13 at 3:06
    
this link will contain only up to date information to solve this problem (compared to this answer which I will not maintain as the rvm site) –  mpapis Jan 13 at 20:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.