【问题标题】:Linode Deban Linux + Nginx + unicorn_railsLinode Deban Linux + Nginx + unicorn_rails
【发布时间】:2011-11-26 22:08:23
【问题描述】:

我是运行 Debian 6 的新 Linode/Linux 用户。我正在尝试让我的 Unicorn 服务器在启动时启动,但由于某种原因它不是,而且我无法追踪任何错误消息. Nginx 开始正常,我安装了多用户 RVM。我的直觉是这与 RVM 有关。这是我在/rails/todo 中的unicorn_init.sh 文件,在/etc/init.d/unicorn 上有一个符号链接:

# unicorn_init.sh
#!/bin/sh

set -e

TIMEOUT=${TIMEOUT-60}
APP_ROOT=/rails/todo
PID=$APP_ROOT/tmp/pids/unicorn.pid
CMD="$APP_ROOT/bin/unicorn_rails -D -c $APP_ROOT/config/unicorn.rb -E production"
GEM_HOME="/usr/local/rvm/gems/ruby-1.9.2-p290@global"
action="$1"
set -u

old_id="$PID.oldbin"

cd $APP_ROOT || exit 1
export GEM_HOME=$GEM_HOME

sig () {
  test -s "$PID" && kill -$1 `cat $PID`
}

oldsig () {
  test -s $old_pid && kill -$1 `cat $old_pid`
}

case $action in
  start)
    sig 0 && echo >&2 "Already running" && exit 0
    su -c "$CMD" - root
    ;;
  stop)
    sig QUIT && exit 0
    echo >&2 "Not running"
    ;;
  force-stop)
    sig TERM && exit 0
    echo >&2 "Not running"
    ;;
  restart|reload)
    sig HUP && echo reloaded OK && exit 0
    echo >&2 "Couldn't reload, starting '$CMD' instead"
    su -c "$CMD" - root
    ;;
  upgrade)
    if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
    then
      n=$TIMEOUT
      while test -s $old_pid && test $n -ge 0
      do
        printf '.' && sleep 1 && n=$(( $n - 1 ))
      done
      echo

      if test $n -lt 0 && test -s $old_pid
      then
        echo >&2 "$old_pid still exists after $TIMEOUT seconds"
        exit 1
      fi
      exit 0
    fi
    echo >&2 "Couldn't upgrade, starting '$CMD' instead"
    su -c "$CMD" - root
    ;;
  reopen-logs)
    sig USR1
    ;;
  *)
    echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
    exit 1
    ;;
esac

我已经完成了 99% 的设置工作 — 任何建议都将不胜感激。

这是$ update-rc.d unicorn defaults的输出:

update-rc.d: using dependency based boot sequencing
insserv: warning: script 'unicorn' missing LSB tags and overrides
insserv: There is a loop between service nginx and unicorn if stopped
insserv:  loop involving service unicorn at depth 2
insserv:  loop involving service nginx at depth 1
insserv: Stopping unicorn depends on nginx and therefore on system facility `$all' which can not be true!
insserv: exiting now without changing boot order!
update-rc.d: error: insserv rejected the script header

【问题讨论】:

    标签: ruby-on-rails nginx debian unicorn


    【解决方案1】:

    update-rc.d: 错误:insserv 拒绝了脚本头

    文件的开头如下所示:

    # unicorn_init.sh
    #!/bin/sh
    

    shebang 行 (#!/bin/sh) 必须是文件的第一行。

    我无法评论循环检测消息,因为我以前从未见过它们。您在 /etc/init.d/nginx 中所说的可能是表达了对 unicorn 的依赖,但我在 unicorn init 中没有看到任何表达对 nginx 的依赖的内容,因此循环不清楚。

    insserv:警告:脚本“独角兽”缺少 LSB 标记和覆盖

    您应该将 LSB 信息添加到您的初始化脚本 http://wiki.debian.org/LSBInitScripts

    【讨论】:

    • 问题在于缺少 LSB 信息。第一条评论只是针对这篇文章的——我应该注意到这一点。
    猜你喜欢
    • 2017-04-12
    • 1970-01-01
    • 1970-01-01
    • 2012-09-01
    • 2015-04-12
    • 2013-02-04
    • 2016-08-28
    • 2015-12-29
    • 1970-01-01
    相关资源
    最近更新 更多