启动时 init.d 脚本的 PATH 问题

Pet*_*rdk 8 ubuntu path init.d

我有一个简单的脚本来启动一个独角兽实例(在 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
Run Code Online (Sandbox Code Playgroud)

调用时它的行为正确: /etc/init.d/unicorn_boot.sh start

我希望它在启动时启动,所以我跑了: update-rc.d -f unicorn_boot.sh defaults

当我现在重新启动时,出现以下错误:

/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. 我怎样才能解决这个问题?

mgo*_*ven 9

Initscripts 负责自己设置合适的路径。$PATH在脚本顶部设置变量:

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
Run Code Online (Sandbox Code Playgroud)