Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

[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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.