如何获得supervisord使用用户的rbenv环境?

我有守护进程拥有,我想有系统pipe理员pipe理。 守护进程有自己的用户,并在ruby中完成,它是自己的rbenv环境。 守护进程的supervisord conf:

[program:hooks] command=/home/hooks/bin/run.sh user=hooks environment=HOME='/home/hooks',USER=hooks,PATH='/home/hooks/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' 

/home/hooks/bin/run.sh看起来像:

 #!/bin/bash -e rbenv init - cd /home/carehooks/src/ bundle install thin --timeout 0 --environment 'production' --rackup `pwd`/config.ru --chdir examples/ start 

现在,结果是:

 # supervisorctl start hooks hooks: ERROR (abnormal termination) # cat /var/log/supervisor/hooks-stderr---supervisor-e2Myrz.log /bin/readlink: missing operand Try `/bin/readlink --help' for more information. /home/hooks/bin/run.sh: line 6: bundle: command not found # cat /var/log/supervisor/hooks-stdout---supervisor-ndpvIv.log export PATH="/home/hooks/.rbenv/shims:${PATH}" source "/home/hooks/.rbenv/libexec/../completions/rbenv.bash" rbenv rehash 2>/dev/null function rbenv() { command="$1" if [ "$#" -gt 0 ]; then shift fi case "$command" in shell) eval `rbenv "sh-$command" "$@"`;; *) command rbenv "$command" "$@";; esac } 

我的supervisordconfiguration是错误还是rbenv? 我怎样才能让两者共存?

rbenv为所有的命令(例如ruby,bundle,…)创build垫片。 这些垫片生活在一个单一的目录(默认〜/ .rbenv /垫片)。 因此,可以使用参数调用home/my_user/.rbenv/shims/command来使用由rbenv定义的命令版本。

find一个示例程序附加我的conf。

 [program:sample_program] directory=/home/my_user/sample_dir command=/home/my_user/.rbenv/shims/ruby server.rb user=my_user autostart=true autorestart=true redirect_stderr=true stdout_logfile=/var/log/sample_program.out