我如何使用 "bundle exec" 告诉 Unicorn 运行 Rails?

How do I tell Unicorn to run Rails using "bundle exec"?

我是 运行 独角兽 Rails 5 Ubuntu 14.04。我是 运行 Unicorn 作为守护进程,使用脚本 /etc/init.d/unicorn,

case "" in
  start)
        check_config
        check_app_root

        log_daemon_msg "Starting $DESC" $NAME || true
        if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $UNICORN_OPTS; then

在单独的文件 /etc/default/unicorn 中,我定义了 DAEMON 和 UNICORN_OPTS 变量...

UNICORN_OPTS="-D -c $CONFIG_RB -E $RAILS_ENV"
...
DAEMON="$GEM_PATH/bin/unicorn"

我的问题是,当它运行 rails 时,我如何告诉 Unicorn 在它前面加上 "bundle exec" 前缀?我需要 bundle exec,因为我在我的独角兽日志中收到了所有这些抱怨 gem 版本以及 bundle exec 如何节省时间。

Bundle 需要 运行 来自应用根目录。

您的 DAEMON 应该类似于 cd $APP_ROOT && $GEM_PATH/bin/bundle exec unicorn