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?
rbenv creates shims for all the commands (e.g. ruby, bundle,...). These shims live in a single directory (~/.rbenv/shims by default). Therefore you can call
home/my_user/.rbenv/shims/command
with parameters to use command version defined by rbenv.Find attached my conf for a sample program.