sstephenson/rbenv — Issue #141: Why won't rbenv co-exist with supervisord? 
Author: blt
Created: 2011-11-09 16:02:08+00:00
State: open

I've daemon owned that I'd like to have system supervisor manage. The daemon has its own user and, being done up in ruby, it's own rbenv environment. The supervisord conf for the daemon:

[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'

where `/home/hooks/bin/run.sh` looks like:

#!/bin/bash -e

rbenv init -

cd /home/carehooks/src/
bundle install

thin --timeout 0 --environment 'production' --rackup `pwd`/config.ru --chdir examples/ start

Now, the result:

# 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
}

Is my supervisord configuration at fault, or rbenv? How can I get the two to co-exist?

---

Duplicated at ServerFault: http://serverfault.com/q/329349/67165