简体   繁体   English

铁路环境mongoid连接问题

[英]rails environment mongoid connection issue

I have rails app 3.2.17, deployed in staging environment with unicorn 4.6.3 monitored by bluepill 0.0.66 using mongid 3.1.5 我有rails app 3.2.17,部署在登台环境中,独角兽4.6.3由bluepill 0.0.66使用mongid 3.1.5监控

When I deploy for staging environment all works find including active_record except mongoid queries with result with following error: 当我为staging环境进行部署时,所有工作都会找到包括active_record在内的mongoid查询,其结果包含以下错误:

Error during failsafe response: 
Problem:
  No configuration could be found for a session named 'default'.
Summary:
  When attempting to create the new session, Mongoid could not find a session configuration for the name: 'default'. This is necessary in order to know the host, port, and options needed to connect.
Resolution:
  Double check your mongoid.yml to make sure under the sessions key that a configuration exists for 'default'. If you have set the configuration programatically, ensure that 'default' exists in the configuration hash.

mongoid.yml file in deployed station 部署站中的mongoid.yml文件

staging:
  sessions:
    default:
      database: mydb
      username: user
      password: password
      hosts:
        - localhost:27017
      options:
  options:

myapp.pill file in deployed station 部署站中的myapp.pill文件

Bluepill.application('myapp', log_file: '/var/log/bluepill/myapp.log') do |app|
    app.process('myapp-app') do |process|
        process.pid_file = '/home/user/myapp/current/tmp/pids/unicorn.pid'
        process.working_dir = '/home/user/myapp/current'
        process.start_command = '/home/user/.gem/ruby/1.9.1/bin/bundle exec unicorn -c config/unicorn.rb -D -E staging'
        process.stop_command = 'kill -QUIT {{PID}}'
        process.restart_command = 'kill -USR2 {{PID}}'
        process.uid = 'user'
        process.gid = 'user'
        process.start_grace_time 30.seconds
        process.stop_grace_time 30.seconds
        process.restart_grace_time 60.seconds
        process.monitor_children do |child_process|
            child_process.stop_command 'kill -QUIT {{PID}}'
            child_process.checks(:mem_usage,
                :every => 30.seconds,
                :below => 1024.megabytes,
                :times => [3,4]
            )
            child_process.checks(:cpu_usage,
                :every => 30.seconds,
                :below => 90,
                :times => [3,4]
            )
        end
    end
end

I suspect that mongoid is not receiving the RAILS_ENV, but I'm not sure, I check indentation in mongoid.yml. 我怀疑mongoid没有收到RAILS_ENV,但我不确定,我检查mongoid.yml中的缩进。 Should another reason that I not find out. 还有其他原因,我不知道。

in /config/application.rb type 在/config/application.rb类型中

require 'mongoid'

Mongoid.load!(File.expand_path('mongoid.yml', './config'))

It may be do it via initializer. 它可以通过初始化器来完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM