Linode Debian + rvm + nginx + Unicorn이 부팅 시 마스터를 종료하거나 유니콘을 시작하지 않습니다.

Linode Debian + rvm + nginx + Unicorn이 부팅 시 마스터를 종료하거나 유니콘을 시작하지 않습니다.

저는 Debian 6을 실행하는 새로운 Linode/Linux 사용자입니다. 부팅 시 Unicorn 서버를 시작하려고 하는데 어떤 이유로 시작되지 않고 오류 메시지를 추적할 수 없습니다. Nginx가 제대로 시작되고 있으며 다중 사용자 RVM이 설치되어 있습니다. 내 직감은 RVM과 관련이 있다는 것입니다. 이것은 내 unicorn_init.sh파일 /rails/todo이고 다음 위치에 심볼릭 링크가 있습니다 /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

답변1

Shebang( #!/bin/sh)은 스크립트의 첫 번째 줄에 있어야 합니다.

편집됨:

shebang 뒤와 응용 프로그램 별 설정 앞에 다음을 입력하십시오.

### BEGIN INIT INFO
# Provides:          APPLICATION
# Required-Start:    $all
# Required-Stop:     $network $local_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the APPLICATION unicorns at boot
# Description:       Enable APPLICATION at boot time.
### END INIT INFO
# 
# Use this as a basis for your own Unicorn init script.
# Make sure that all paths are correct.

set -u
set -e

LSB 경고를 반드시 제거해야 합니다.

관련 정보