Rails app未加载Passenger + Nginx

时间:2017-11-17 11:15:46

标签: ruby-on-rails nginx passenger

我正在尝试部署到生产环境中的Rails应用程序。我有Nginx的Passenger设置,看着Nginx日志,乘客正在启动但是当我尝试浏览到我的应用程序时,错误日志填满了以下内容:

App 67160 stdout: 
App 67160 stdout: 
[ E 2017-11-17 11:06:39.5087 67125/Th age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /var/www/vuln_frontend: An error occurred while starting up the preloader.
  Error ID: bd9a976b
  Error details saved to: /tmp/passenger-error-okz7mL.html
  Message from application: cannot load such file -- bundler/setup (LoadError)
  /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:456:in `activate_gem'
  /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:323:in `block in run_load_path_setup_code'
  /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:461:in `running_bundler'
  /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:322:in `run_load_path_setup_code'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'


[ E 2017-11-17 11:06:39.5121 67125/T9 age/Cor/Con/CheckoutSession.cpp:285 ]: [Client 2-1] Cannot checkout session because a spawning error occurred. The identifier of the error is bd9a976b. Please see earlier logs for details about the error.

我已检入/ tmp /但没有/tmp/passenger-error-okz7mL.html 文件,我的系统Ruby是2.4.2,与我的应用程序使用的相同,与RVM版本相同。

我无法看到问题出在哪里,我的宝石在应用和系统中都是最新的。

我可以加载Passenger错误页面,但没有别的。

我启用了riendly错误页面并获得了以下输出:

详细说明:

cannot load such file -- bundler/setup (LoadError)
  /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:456:in `activate_gem'
  /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:323:in `block in run_load_path_setup_code'
  /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:461:in `running_bundler'
  /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:322:in `run_load_path_setup_code'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'

System information:

Application root
    /var/www/vuln_frontend
Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV, NODE_ENV and PASSENGER_APP_ENV)
    production
Ruby interpreter command

    /usr/bin/ruby

User and groups

    uid=99(nobody) gid=99(nobody) groups=99(nobody)

Environment variables

    PASSENGER_USE_FEEDBACK_FD = true
    SERVER_SOFTWARE = nginx/1.12.1 Phusion_Passenger/5.1.11
    PASSENGER_DEBUG_DIR = /tmp/passenger.spawn-debug.XXXXMTSagL
    USER = nobody
    LOGNAME = nobody
    SHELL = /sbin/nologin
    HOME = /
    PWD = /var/www/vuln_frontend
    IN_PASSENGER = 1
    PYTHONUNBUFFERED = 1
    NODE_PATH = /usr/share/passenger/node
    RAILS_ENV = production
    RACK_ENV = production
    WSGI_ENV = production
    NODE_ENV = production
    PASSENGER_APP_ENV = production

Ulimits

    Unknown

System metrics

    ------------- General -------------
    Kernel version    : 3.10.0-693.5.2.el7.x86_64
    Uptime            : 1d 21h 16m 17s
    Load averages     : 0.00%, 0.01%, 0.05%
    Fork rate         : unknown

    ------------- CPU -------------
    Number of CPUs    :    2
    Average CPU usage :   0%  --   0% user,   0% nice,   0% system, 100% idle
      CPU 1           :   0%  --   0% user,   0% nice,   0% system, 100% idle
      CPU 2           :   0%  --   0% user,   0% nice,   0% system, 100% idle
    I/O pressure      :   0%
      CPU 1           :   0%
      CPU 2           :   0%
    Interference from other VMs:   0%
      CPU 1                    :   0%
      CPU 2                    :   0%

    ------------- Memory -------------
    RAM total         :   1823 MB
    RAM used          :    543 MB (30%)
    RAM free          :   1279 MB
    Swap total        :   2047 MB
    Swap used         :      0 MB (0%)
    Swap free         :   2047 MB
    Swap in           : unknown
    Swap out          : unknown

General Ruby interpreter information

    RUBY_VERSION = 2.0.0
    RUBY_PLATFORM = x86_64-linux
    RUBY_ENGINE = ruby
    RubyGems version = 2.0.14.1
    RubyGems paths = ["/.gem/ruby", "/usr/share/gems", "/usr/local/share/gems"]

Ruby configuration (RbConfig::CONFIG)

    DESTDIR = 
    MAJOR = 2
    MINOR = 0
    TEENY = 0
    PATCHLEVEL = 648
    INSTALL = /usr/bin/install -c
    EXEEXT = 
    prefix = /usr
    ruby_install_name = ruby
    RUBY_INSTALL_NAME = ruby
    RUBY_SO_NAME = ruby
    exec = exec
    ruby_pc = ruby.pc
    PACKAGE = ruby
    BUILTIN_TRANSSRCS =  newline.c
    USE_RUBYGEMS = YES
    MANTYPE = doc
    NROFF = /usr/bin/nroff
    OPTIONAL_PRELUDES = ./abrt_prelude.rb
    vendorarchhdrdir = /usr/include/vendor_ruby/x86_64-linux
    sitearchhdrdir = /usr/include/site_ruby/x86_64-linux
    rubyarchhdrdir = /usr/include
    vendorhdrdir = /usr/include/vendor_ruby
    sitehdrdir = /usr/include/site_ruby
    rubyhdrdir = /usr/include
    UNIVERSAL_INTS = 
    UNIVERSAL_ARCHNAMES = 
    configure_args =  '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-rubylibprefix=/usr/share/ruby' '--with-rubyarchprefix=/usr/lib64/ruby' '--with-sitedir=/usr/local/share/ruby/site_ruby' '--with-sitearchdir=/usr/local/lib64/ruby/site_ruby' '--with-vendordir=/usr/share/ruby/vendor_ruby' '--with-vendorarchdir=/usr/lib64/ruby/vendor_ruby' '--with-rubyhdrdir=/usr/include' '--with-rubyarchhdrdir=/usr/include' '--with-sitearchhdrdir=/usr/include/site_ruby/x86_64-linux' '--with-vendorarchhdrdir=/usr/include/vendor_ruby/x86_64-linux' '--with-rubygemsdir=/usr/share/rubygems' '--with-ruby-pc=ruby.pc' '--disable-rpath' '--enable-shared' '--with-ruby-version=' '--enable-multiarch' '--with-prelude=./abrt_prelude.rb' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic' 'LDFLAGS=-Wl,-z,relro ' 'CXXFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic'
    rubygemsdir = /usr/share/rubygems
    vendorarchdir = /usr/lib64/ruby/vendor_ruby
    vendorlibdir = /usr/share/ruby/vendor_ruby/
    vendordir = /usr/share/ruby/vendor_ruby
    sitearchdir = /usr/local/lib64/ruby/site_ruby
    sitelibdir = /usr/local/share/ruby/site_ruby/
    sitedir = /usr/local/share/ruby/site_ruby
    rubyarchdir = /usr/lib64/ruby/
    rubylibdir = /usr/share/ruby/
    ruby_version = 
    sitearch = x86_64-linux
    arch = x86_64-linux
    sitearchincludedir = /usr/include/x86_64-linux
    archincludedir = /usr/include/x86_64-linux
    sitearchlibdir = /usr/lib64/x86_64-linux
    archlibdir = /usr/lib64/x86_64-linux
    RI_BASE_NAME = ri
    ridir = /usr/share/ri
    rubysitearchprefix = /usr/lib64/x86_64-linux/ruby
    rubyarchprefix = /usr/lib64/ruby
    rubylibprefix = /usr/share/ruby
    MAKEFILES = Makefile
    PLATFORM_DIR = 
    THREAD_MODEL = pthread
    SYMBOL_PREFIX = 
    EXPORT_PREFIX = 
    COMMON_HEADERS = 
    COMMON_MACROS = 
    COMMON_LIBS = 
    MAINLIBS = 
    ENABLE_SHARED = yes
    DLDLIBS =  -lc
    SOLIBS = -lpthread -lrt -ldl -lcrypt -lm 
    LIBRUBYARG_SHARED = -lruby
    LIBRUBYARG_STATIC = -lruby-static
    LIBRUBYARG = -lruby
    LIBRUBY = libruby.so.2.0.0
    LIBRUBY_ALIASES = libruby.so.2.0 libruby.so
    LIBRUBY_SO = libruby.so.2.0.0
    LIBRUBY_A = libruby-static.a
    RUBYW_INSTALL_NAME = 
    rubyw_install_name = 
    LIBRUBY_DLDFLAGS = -Wl,-soname,libruby.so.2.0 
    LIBRUBY_LDSHARED = gcc -shared
    EXTDLDFLAGS = 
    EXTLDFLAGS = 
    strict_warnflags = -ansi -std=iso9899:199409
    warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
    debugflags = -ggdb3
    optflags = -O3 -fno-fast-math
    cxxflags =  -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
    cflags =  -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
    cppflags = 
    NULLCMD = :
    DLNOBJ = dln.o
    INSTALLDOC = all
    CAPITARGET = nodoc
    RDOCTARGET = rdoc
    DTRACE_GLOMMED_OBJ = ruby-glommed.o
    DTRACE_OBJ = probes.o
    DTRACE_EXT = d
    EXECUTABLE_EXTS = 
    ARCHFILE = 
    LIBRUBY_RELATIVE = no
    EXTOUT = .ext
    RUNRUBY_COMMAND = $(MINIRUBY) $(srcdir)/tool/runruby.rb --extout=.ext $(RUNRUBYOPT)
    PREP = miniruby
    BTESTRUBY = $(MINIRUBY)
    CROSS_COMPILING = no
    TEST_RUNNABLE = yes
    setup = Setup
    EXTSTATIC = 
    STRIP = strip -S -x
    TRY_LINK = 
    LIBPATHENV = LD_LIBRARY_PATH
    RPATHFLAG = 
    LIBPATHFLAG =  -L%s
    LINK_SO = 
    LIBEXT = a
    DLEXT2 = 
    DLEXT = so
    LDSHAREDXX = g++ -shared
    LDSHARED = gcc -shared
    CCDLFLAGS = -fPIC
    STATIC = 
    ARCH_FLAG = -m64
    DLDFLAGS = 
    ALLOCA = 
    codesign = 
    POSTLINK = :
    WERRORFLAG = -Werror
    CHDIR = cd -P
    RMALL = rm -fr
    RMDIRS = rmdir --ignore-fail-on-non-empty -p
    RMDIR = rmdir --ignore-fail-on-non-empty
    CP = cp
    RM = rm -f
    PKG_CONFIG = pkg-config
    PYTHON = 
    DOXYGEN = 
    DOT = 
    DTRACE = dtrace
    MAKEDIRS = /usr/bin/mkdir -p
    MKDIR_P = /usr/bin/mkdir -p
    INSTALL_DATA = /usr/bin/install -c -m 644
    INSTALL_SCRIPT = /usr/bin/install -c
    INSTALL_PROGRAM = /usr/bin/install -c
    SET_MAKE = 
    LN_S = ln -s
    NM = nm
    DLLWRAP = 
    WINDRES = 
    OBJCOPY = :
    OBJDUMP = objdump
    ASFLAGS = 
    AS = as
    AR = ar
    RANLIB = ranlib
    try_header = 
    COUTFLAG = -o 
    OUTFLAG = -o 
    CPPOUTFILE = -o conftest.i
    GNU_LD = yes
    LD = ld
    GCC = yes
    EGREP = /usr/bin/grep -E
    GREP = /usr/bin/grep
    CPP = gcc -E
    CXXFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic
    CXX = g++
    OBJEXT = o
    CPPFLAGS =   
    LDFLAGS = -L. -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic
    CFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic -fPIC
    CC = gcc
    NACL_SDK_VARIANT = 
    NACL_SDK_ROOT = 
    NACL_TOOLCHAIN = 
    target_os = linux
    target_vendor = redhat
    target_cpu = x86_64
    target = x86_64-redhat-linux-gnu
    host_os = linux-gnu
    host_vendor = redhat
    host_cpu = x86_64
    host = x86_64-redhat-linux-gnu
    RUBY_VERSION_NAME = ruby-
    RUBYW_BASE_NAME = rubyw
    RUBY_BASE_NAME = ruby
    build_os = linux-gnu
    build_vendor = redhat
    build_cpu = x86_64
    build = x86_64-redhat-linux-gnu
    RUBY_RELEASE_DATE = 2015-12-16
    RUBY_PROGRAM_VERSION = 2.0.0
    target_alias = 
    host_alias = x86_64-redhat-linux-gnu
    build_alias = x86_64-redhat-linux-gnu
    LIBS = -lpthread -lrt -ldl -lcrypt -lm 
    ECHO_T = 
    ECHO_N = -n
    ECHO_C = 
    DEFS = 
    mandir = /usr/share/man
    localedir = /usr/share/locale
    libdir = /usr/lib64
    psdir = /usr/share/doc/ruby
    pdfdir = /usr/share/doc/ruby
    dvidir = /usr/share/doc/ruby
    htmldir = /usr/share/doc/ruby
    infodir = /usr/share/info
    docdir = /usr/share/doc/ruby
    oldincludedir = /usr/include
    includedir = /usr/include
    localstatedir = /var
    sharedstatedir = /var/lib
    sysconfdir = /etc
    datadir = /usr/share
    datarootdir = /usr/share
    libexecdir = /usr/libexec
    sbindir = /usr/sbin
    bindir = /usr/bin
    exec_prefix = /usr
    PACKAGE_URL = 
    PACKAGE_BUGREPORT = 
    PACKAGE_STRING = 
    PACKAGE_VERSION = 
    PACKAGE_TARNAME = 
    PACKAGE_NAME = 
    PATH_SEPARATOR = :
    SHELL = /bin/sh
    archdir = /usr/lib64/ruby/
    topdir = /usr/lib64/ruby

Ruby load path ($LOAD_PATH)

    /usr/local/share/ruby/site_ruby
    /usr/local/lib64/ruby/site_ruby
    /usr/share/ruby/vendor_ruby
    /usr/lib64/ruby/vendor_ruby
    /usr/share/rubygems
    /usr/share/ruby
    /usr/lib64/ruby/

Ruby loaded libraries ($LOADED_FEATURES)

    enumerator.so
    /usr/lib64/ruby/enc/encdb.so
    /usr/lib64/ruby/enc/trans/transdb.so
    /usr/lib64/ruby/rbconfig.rb
    /usr/share/rubygems/rubygems/compatibility.rb
    /usr/share/rubygems/rubygems/defaults.rb
    /usr/share/rubygems/rubygems/deprecate.rb
    /usr/share/rubygems/rubygems/errors.rb
    /usr/share/rubygems/rubygems/version.rb
    /usr/share/rubygems/rubygems/requirement.rb
    /usr/share/rubygems/rubygems/platform.rb
    /usr/share/rubygems/rubygems/specification.rb
    /usr/share/rubygems/rubygems/exceptions.rb
    /usr/share/rubygems/rubygems/defaults/operating_system.rb
    /usr/share/rubygems/rubygems/core_ext/kernel_gem.rb
    /usr/share/ruby/thread.rb
    /usr/share/ruby/monitor.rb
    /usr/share/rubygems/rubygems/core_ext/kernel_require.rb
    /usr/share/rubygems/rubygems.rb
    /usr/share/rubygems/rubygems/path_support.rb
    /usr/share/rubygems/rubygems/dependency.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/constants.rb
    /usr/lib64/ruby/etc.so
    /usr/share/ruby/fileutils.rb
    /usr/share/ruby/tmpdir.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/utils/tmpio.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/platform_info.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/platform_info/operating_system.rb
    /usr/lib64/ruby/vendor_ruby/passenger_native_support.so
    /usr/share/ruby/vendor_ruby/phusion_passenger/native_support.rb
    /usr/lib64/ruby/socket.so
    /usr/share/ruby/socket.rb
    /usr/lib64/ruby/pathname.so
    /usr/share/ruby/pathname.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/ruby_core_enhancements.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/ruby_core_io_enhancements.rb
    /usr/share/ruby/base64.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/utils.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/preloader_shared_helpers.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/public_api.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/debug_logging.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/platform_info/ruby.rb
    /usr/share/ruby/shellwords.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/utils/shellwords.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb
    /usr/lib64/ruby/fcntl.so
    /usr/share/ruby/vendor_ruby/phusion_passenger/message_channel.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/message_client.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/utils/native_support_utils.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/utils/unseekable_socket.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/request_handler.rb
    /usr/lib64/ruby/stringio.so
    /usr/share/ruby/vendor_ruby/phusion_passenger/utils/tee_input.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version.rb
    /usr/share/ruby/vendor_ruby/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails.rb

1 个答案:

答案 0 :(得分:0)

Passenger正在使用/usr/bin/ruby,您希望它使用RVM Ruby。您需要告诉Passenger运行您的应用程序应该使用哪个Ruby命令,因为您的系统上有多个Ruby解释器。请运行passenger-config about ruby-command以找出您正在使用的Ruby解释器。例如:

passenger-config about ruby-command
passenger-config was invoked through the following Ruby interpreter:
  Command: /usr/local/rvm/gems/ruby-2.3.3/wrappers/ruby
  Version: ruby 2.3.3p85 (2015-02-26 revision 49769) [x86_64-linux]
  ...

请注意“命令”之后的路径(在此示例中为/usr/local/rvm/gems/ruby-2.3.3/wrappers/ruby)。您需要将passenger_ruby配置选项设置为此路径。

https://www.phusionpassenger.com/library/deploy/nginx/deploy/ruby/#determine_ruby_command