Bash脚本中另一个用户下的Ruby RVM
通过su命令和其他脚本在其他用户下启动ruby脚本的最佳方式是什么 我有一个bash脚本,其中包含用于启动unicorn的以下命令:Bash脚本中另一个用户下的Ruby RVM,ruby,bash,rvm,sudo,su,Ruby,Bash,Rvm,Sudo,Su,通过su命令和其他脚本在其他用户下启动ruby脚本的最佳方式是什么 我有一个bash脚本,其中包含用于启动unicorn的以下命令: sudo -u unicornuser sh -l -c "bundle exec unicorn_rails -E production -D" 此脚本是一个init.d脚本,它在系统启动时执行,也可以手动执行 问题是默认的Rubyon系统是1.8,其他rubyes(1.9)在RVM下工作。我需要修改上面的脚本,使其能够使用RVM(非系统范
sudo -u unicornuser sh -l -c "bundle exec unicorn_rails -E production -D"
此脚本是一个init.d脚本,它在系统启动时执行,也可以手动执行
问题是默认的Rubyon系统是1.8,其他rubyes(1.9)在RVM下工作。我需要修改上面的脚本,使其能够使用RVM(非系统范围)执行ruby
现在,我迁移了这个符号:
su -l -c "rvm use ruby-1.9.3-p125 && bundle exec unicorn_rails -E production -D" unicornuser
这对我来说很有效,但我想一定有更好的方法可以做到这一点。你应该使用包装器:
rvm wrapper ruby-1.9.3-p125 ext_1.9.3 bundle
这将创建$rvm_path/bin/ext_1.9.3_bundle
,因此现在您可以使用:
/full/path/to/rvm/bin/ext_1.9.3_bundle exec unicorn_rails -E production -D
将/full/path/to/rvm
替换为echo$rvm_path