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

I have a simple script that starts up a unicorn instance (on Ubuntu 12.04LTS).

#!/bin/sh

case "$1" in
    start)
       echo "starting"
       cd /path && bundle exec unicorn -c /path/config/unicorn.rb -D -E production
      ;;
     stop)
      echo "Stopping Unicorn Instances"
      kill `cat /tmp/unicorn.pid`
    ;;
    restart)
    echo "sending USR2 to all unicorns"
    kill -s USR2 `cat /tmp/unicorn.pid`
    ;;
esac
exit 0

It behaves correctly when called: /etc/init.d/unicorn_boot.sh start

I want it to start on boot, so I ran: update-rc.d -f unicorn_boot.sh defaults

When I now reboot I get the following error:

/etc/rc2.d/S20unicorn_boot.sh: 10: /etc/rc2.d/S20unicorn_boot.sh: bundle: not found

I checked the bundle command, and it's installed in /usr/local/bin, same for the ruby command.

It appears that on boot the PATH does not yet include /usr/local/bin. How can I fix this?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Initscripts are responsible for setting an appropriate path themselves. Set the $PATH variable at the top of the script:

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
share|improve this answer
    
Ok, thanks. Didn't know that. It's fixed now! –  Peterdk Feb 22 '13 at 23:00

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.