rails环境mongoid连接问题 [英] rails environment mongoid connection issue
问题描述
我有rails app 3.2.17,部署在 staging 环境中,由unicorn 4.6.3监视bluepill 0.0.66使用mongid 3.1.5
在故障安全期间发生错误响应:
问题:
无法找到名为default的会话的配置。
摘要:
尝试创建新会话时,Mongoid找不到名称为default的会话配置。这是必要的,以了解连接所需的主机,端口和选项。
解决方案:
仔细检查您的mongoid.yml以确保在会话密钥下存在default配置。如果您以编程方式设置配置,请确保配置哈希中存在默认。
部署站的mongoid.yml 文件
staging:
会话:
默认值:
数据库:mydb
用户名:用户
密码:密码
主机:
- 本地主机:27017
选项:
选项:
已部署站的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'
进程。 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
我怀疑mongoid没有收到RAILS_ENV,但我不确定,我检查mongoid.yml中的缩进。另一个原因,我没有发现。/ / p>
在/config/application.rb类型
require'mongoid'
Mongoid.load!(File.expand_path('mongoid.yml','./config'))
它可能是通过初始化程序。
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
When I deploy for staging environment all works find including active_record except mongoid queries with result with following error:
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
staging:
sessions:
default:
database: mydb
username: user
password: password
hosts:
- localhost:27017
options:
options:
myapp.pill file in deployed station
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. Should another reason that I not find out.
in /config/application.rb type
require 'mongoid'
Mongoid.load!(File.expand_path('mongoid.yml', './config'))
It may be do it via initializer.
这篇关于rails环境mongoid连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!