简体   繁体   English

使用upstart通过rbenv install ruby​​运行ruby脚本

[英]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. 我想在通过Rbenv安装了Ruby 2.1.1的情况下运行脚本。 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. 如果我运行以custom_user身份登录的命令,它将运行完美。 In the application directory I have the Gemfile . application目录中,我有Gemfile

Upstart give me the following error message: script main process (28879) terminated with status 127 新贵给我以下错误消息: script main process (28879) terminated with status 127

The solution is to specify the full path of bundle : 解决方案是指定bundle的完整路径:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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