2 Changes made all the difference:
1) Add hard quotes to EOT in exec /bin/bash << 'EOT' (credit Mat, thanks!)
2) Instead of loading .bashrc using the source, add the rbenv lines from .bashrc directly to the upstart script. Replace source /home/deploy/.bashrc with:
export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
I have no idea why these two changes made a difference, and if this is due to a newer version of ubuntu, upstart or bash. If anyone can explain, please call.
I have included my full script work for those just looking for an answer:
# /etc/init/sidekiq.conf - Sidekiq config # This example config should work with Ubuntu 12.04+. It # allows you to manage multiple Sidekiq instances with # Upstart, Ubuntu native service management tool. # # See workers.conf for how to manage all Sidekiq instances at once. # # Save this config as /etc/init/sidekiq.conf then mange sidekiq with: # sudo start sidekiq index=0 # sudo stop sidekiq index=0 # sudo status sidekiq index=0 # # or use the service command: # sudo service sidekiq {start,stop,restart,status} # description "Sidekiq Background Worker" # no "start on", we don't want to automatically start stop on (stopping workers or runlevel [06]) # change to match your deployment user setuid deploy setgid deploy respawn respawn limit 3 30 # TERM is sent by sidekiqctl when stopping sidekiq. Without declaring these as normal exit codes, it just respawns. normal exit 0 TERM instance $index script # this script runs in /bin/sh by default # respawn as bash so we can source in rbenv exec /bin/bash << 'EOT' # use syslog for logging # exec &> /dev/kmsg # pull in system rbenv export HOME=/home/deploy echo "$HOME" #source /home/deploy/.bashrc export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH" echo "$PATH" cd /home/deploy/domain_freek/current echo "user is $(whoami) and pwd is $(pwd) and rbenv is located at $(which rbenv)" exec bundle exec sidekiq -i ${index} -e production EOT end script
source share