簡體   English   中英

Ruby on Rails與獨角獸不可讀文件

[英]Ruby on rails with unicorn not readable file

我正在嘗試在Rails環境中構建ruby,但是當我檢查獨角獸狀態時,它給了我以下錯誤,我不知道該怎么辦。 我檢查了config.rb的路徑,它在那里。

/usr/local/rvm/gems/ruby-2.2.2/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:644:in `parse_rackup_file': rackup file (status) not readable (ArgumentError)
    from /usr/local/rvm/gems/ruby-2.2.2/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:74:in `reload'
    from /usr/local/rvm/gems/ruby-2.2.2/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:65:in `initialize'
    from /usr/local/rvm/gems/ruby-2.2.2/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:76:in `new'
    from /usr/local/rvm/gems/ruby-2.2.2/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:76:in `initialize'
    from /usr/local/rvm/gems/ruby-2.2.2/gems/unicorn-5.1.0/bin/unicorn:126:in `new'
    from /usr/local/rvm/gems/ruby-2.2.2/gems/unicorn-5.1.0/bin/unicorn:126:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.2.2/bin/unicorn:23:in `load'
    from /usr/local/rvm/gems/ruby-2.2.2/bin/unicorn:23:in `<main>'
    from /usr/local/rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
    from /usr/local/rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'

獨角獸配置

#!/bin/bash
### BEGIN INIT INFO
# Provides:          unicorn
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: unicorn initscript
# Description:       Unicorn is an HTTP server for Rack application
### END INIT INFO

# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
##
## RAILS_ENV=production
## RAILS_ROOT=/var/apps/www/my_app/current
## PID=$RAILS_ROOT/tmp/unicorn.pid
## START_CMD="bundle exec unicorn"
## USER="www-data"
#PATH=/usr/local/bin:/usr/bin:/bin

set -e


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

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

run_cmd() {
  if [ -z "$SUDO" ]; then
    $CMD
  else
    $SUDO "$CMD"
  fi
}

cmd () {


  case $1 in
    start)
      sig 0 && echo >&2 "Already running" && return
      echo "Starting"
      run_cmd
      ;;
    stop)
      sig QUIT && echo "Stopping" && return
      echo >&2 "Not running"
      ;;
    force-stop)
      sig TERM && echo "Forcing a stop" && return
      echo >&2 "Not running"
      ;;
    restart|reload)
      sig USR2 && sleep 5 && oldsig QUIT && echo "Killing old master" `cat $OLD_PID` && return
      echo >&2 "Couldn't reload, starting '$CMD' instead"
      run_cmd
      ;;
    upgrade)
      sig USR2 && echo Upgraded && return
      echo >&2 "Couldn't upgrade, starting '$CMD' instead"
     run_cmd
      ;;
    rotate)
      sig USR1 && echo rotated logs OK && return
      echo >&2 "Couldn't rotate logs" && return
      ;;
    status)
      sig 0 && echo >&2 "Already running" && return
      echo >&2 "Not running" && return
      ;;
    *)
      echo >&2 "Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
      return
      ;;
    esac
}

setup () {
#  echo -n "$RAILS_ROOT: "
  cd $RAILS_ROOT || exit 1

"/usr/local/rvm/scripts/rvm"
#/usr/local/rvm/environments/ruby-1.9.2-p290@hacfest

  if [ -z "$PID" ]; then
    PID=$RAILS_ROOT/tmp/pids/unicorn.pid
  fi

#  if [ -z "$DATABASE_URL" ]; then
#    DATABASE_URL=null
#  fi

#  export DATABASE_URL
  export PID
  export OLD_PID="$PID.oldbin"
  export RAILS_ROOT
  if [ -z "$START_CMD" ]; then
    START_CMD="bundle exec unicorn"
  fi
  CMD="cd $RAILS_ROOT && $START_CMD -c $UNICORN_CONFIG -E $RAILS_ENV -D"
  export CMD
  echo "CMD: " $CMD

  SUDO=""
#  echo who: `whoami`
#  echo user $USER
  if [ "$USER" != `whoami` ]; then
    SUDO="sudo -u $USER -s -H $RUNSHELL -c"
  else
    SUDO="$RUNSHELL -c"
  fi
  export SUDO
#  echo "SUDO: "$SUDO
#  echo $SHELL
}

start_stop () {

  # either run the start/stop/reload/etc command for every config under /etc/unicorn
  # or just do it for a specific one

  # $1 contains the start/stop/etc command
  # $2 if it exists, should be the specific config we want to act on
  if [ -f "/etc/unicorn/$2.conf" ]; then
    . /etc/unicorn/$2.conf
    export UNICORN_CONFIG="/etc/unicorn/$2.unicorn.rb"
    setup
    cmd $1
  else
    for CONFIG in /etc/unicorn/*.conf; do
      # import the variables
      export UNICORN_CONFIG=`echo ${CONFIG} | sed 's/conf/unicorn.rb/'`
      . $CONFIG
      setup

      # run the start/stop/etc command
      cmd $1
      unset PID
    done
   fi
}

ARGS="$1 $2"
start_stop $ARGS

確保通過命令運行unicorn

bundle exec unicorn -D -E <environment> -c config/unicorn.rb

如果不起作用,請共享您的文件config/unicorn.rb

路徑中存在的文件並不意味着特定用戶可以讀取。 檢查您在其下運行獨角獸的用戶是否有權訪問文件和目錄。 通常,代碼所有者和獨角獸用戶是相同的,因此請使用chown -R that_username:that_username /path/to/app/source

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM