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?
Initscripts are responsible for setting an appropriate path themselves. Set the
$PATH
variable at the top of the script: