简体   繁体   中英

Use upstart to run a ruby script with rbenv install ruby

I want to run a script with Ruby 2.1.1 installed via Rbenv. Here is my upstart script:

start on runlevel [2345]
stop on runlevel [!2345]

setuid custom_user
setgid custom_user

script
        cd /home/custom_user/application/ && rbenv shell 2.1.1 && bundle exec ruby script.rb
end script

If I run that command logged as the custom_user it works perfectly. In the application directory I have the Gemfile .

Upstart give me the following error message: script main process (28879) terminated with status 127

The solution is to specify the full path of bundle :

script
  cd /home/custom_user/application/ && /home/custom_user/.rbenv/shims/bundle exec ruby script.rb
end script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM