2012-12-24 2 views
3

nginx 및 unicorn을 사용하여 ec2 인스턴스에서 레일즈 앱을 설치하려고 반복적으로 시도했습니다. 나는 nginx와 unicorn이 모두 올바르게 설정되었음을 발견했다. 그러나 두 시스템 모두 내 레일 앱은 프로덕션 환경에서 시작하고 싶지 않습니다. 생산을 시작하려고 시도의 출력은 다음과 같습니다 비록레일 앱이 ActiveRecord로 인해 프로덕션 환경에서 시작되지 않음

/Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified) 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:129:in `establish_connection' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:25:in `each' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:25:in `on_load' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/railtie.rb:74:in `block in <class:Railtie>' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing' 
    from /Users/benvreed/Documents/rubydev/StudyPublic/config/environment.rb:5:in `<top (required)>' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require' 
    from /Users/benvreed/Documents/rubydev/StudyPublic/config.ru:4:in `block in <main>' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize' 
    from /Users/benvreed/Documents/rubydev/StudyPublic/config.ru:1:in `new' 
    from /Users/benvreed/Documents/rubydev/StudyPublic/config.ru:1:in `<main>' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:200:in `app' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/server.rb:46:in `app' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/server.rb:70:in `start' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:55:in `block in <top (required)>' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 

, 내가 분명히 내 database.yml 파일에서 PostgreSQL의 어댑터를 지정하십시오

# PostgreSQL. Versions 8.2 and up are supported. 
# 
# Install the pg driver: 
# gem install pg 
# On Mac OS X with macports: 
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 
# On Windows: 
# gem install pg 
#  Choose the win32 build. 
#  Install PostgreSQL and put its /bin directory on your path. 
# 
# Configure Using Gemfile 
# gem 'pg' 
# 
development: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: study_development 
    pool: 5 

    # Connect on a TCP socket. Omitted by default since the client uses a 
    # domain socket that doesn't need configuration. Windows does not have 
    # domain sockets, so uncomment these lines. 
    #host: localhost 
    #port: 5432 

    # Schema search path. The server defaults to $user,public 
    #schema_search_path: myapp,sharedapp,public 

    # Minimum log levels, in increasing order: 
    # debug5, debug4, debug3, debug2, debug1, 
    # log, notice, warning, error, fatal, and panic 
    # The server defaults to notice. 
    #min_messages: warning 

# Warning: The database defined as "test" will be erased and 
# re-generated from your development database when you run "rake". 
# Do not set this db to the same as development or production. 
test: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: study_test 
    pool: 5 

production: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: study_production 
    pool: 5 

정말로 이상한 것은 성공적 모두에서 실행한다는 것입니다 개발 및 테스트 환경. StackOverflow에서 다른 문제를 확인했으며 대부분이 간격 문제라고했습니다. 그러나 동일한 결과로 database.yml 파일을 여러 번 다시 작성했습니다.

내 유니콘 및 nginx 파일은 표준 구성입니다.

도움을 주시면 감사하겠습니다. 이 때까지 나는 서있다. 미리 감사드립니다.

RAILS_ENV RAILS_ENV를 실행

RAILS_ENV=production rails c을 실행하여 레일 콘솔을 사용하여는 생산 :

NameError: uninitialized constant RAILS_ENV 
    from (irb):1 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start' 
    from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 

Rails.env가 생성됩니다

=> "production" 
+0

당신은 당신의'RAILS_ENV' 환경 변수의 값을 제공 할 수 있을까요? –

+0

위 출력을 제공했습니다. – codeblooded

+0

그래서 레일스 콘솔을 시작할 수는 있지만 유니콘과 nginx를 통해 서버를 사용할 수 없습니까? 그 부분을 파헤 치기 시작할 것입니다. –

답변

0

내 설정이 사용

production: 
    adapter: pg 
    encoding: utf8 
    reconnect: false 
    database: my_app_name_production 
+0

'adapter : pg'를 사용하려고 시도했습니다. 응답 :'/Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in' require ': pg adapter를 설치하십시오 :'gem install activerecord-pg-adapter' (그러한 파일을로드 할 수 없습니다 - active_record/connection_adapters/pg_adapter) (LoadError)'. 나는 pg gem과 postgresql을 설치했다. – codeblooded

+0

'gem install activerecord-pg-adapter'를 어떻게하면됩니까? –

+0

그것은 사용할 수 없다고 알려줍니다. 'ERROR : 어떤 저장소에서도 유효한 'activerecord-pg-adapter'(> = 0)을 찾을 수 없습니다. ' – codeblooded

1

database.yml의 어댑터는 postgresql이 아닌 pg 여야합니다.

production: 
    adapter: pg 
    encoding: unicode 
    host: localhost 
    database: study_development 
0

귀하의 database.yml 설정은 정상입니다. 이상한 건 없어요.

개발 모드가 예외없이 실행되면 문제가 DB에 없습니다.

database.yml을 정확하게 확인하십시오. 아마도 잘못되었거나 사용할 수없는 * 문자 일 수 있습니다.


  • 일부 기호는 매우 유사한 :)의 с와 C
0

오류를 포크 (fork)입니다! 일부 캐싱 또는 로그 문제 코드에 오류가 없음을 보여줍니다.

우리 팀이 해결합니다.

  • 프로젝트를

  • 자식 복제 데이터베이스를 config (설정) 프로젝트

  • 을 삭제합니다.YML

  • 시작 서버는

다 괜찮습니다!

동일한 프로젝트 오류가 사라졌습니다! 그래서 우리는 그것이 env 문제이거나 cach 또는 log라고 생각합니다.

는 여기를 참조하십시오 (https://stackoverflow.com/posts/18695551/edit는)

관련 문제