我有一个简单的脚本启动一个unicorn实例(在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
调用时它的行为正确:/etc/init.d/unicorn_boot.sh start
我希望它在启动时启动,所以我运行:
update-rc.d -f unicorn_boot.sh默认值
当我现在重新启动时,我收到以下错误:
/etc/rc2.d/S20unicorn_boot.sh:10:/etc/rc2.d/S20unicorn_boot.sh:bundle:not found
我检查了bundle命令,它安装在/usr/local / bin中,对于ruby命令也是如此.
看起来在启动时PATH还没有包含/usr/local / bin.我怎样才能解决这个问题?
Initscripts负责自己设置适当的路径.在脚本顶部设置$PATH变量:
- PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin