gpt4 book ai didi

mongodb - 如何将 rails + mongodb 应用程序部署到实际域?

转载 作者:可可西里 更新时间:2023-11-01 10:01:02 25 4
gpt4 key购买 nike

我关注了this tutorial使用 Mongoid 和 Mongodb 设置基本的 Rails 4 应用程序。

我在服务器上设置了 Passenger 以进行部署。当我访问 domain.com:3000 时,应用程序可以正常工作。此外,当我访问 domain.com:28017 时,它显示 mongodb 正在运行。

在所有示例/教程中,我可以找到该应用程序托管在 localhost:3000,而我正在尝试部署到我的实际域。

当我访问 domain.com 时,我收到以下错误消息:

Problem:
No sessions configuration provided.
Summary:
Mongoid's configuration requires that you provide details about each session that can be connected to, and requires in the sessions config at least 1 default session to exist.
Resolution:
Double check your mongoid.yml to make sure that you have a top-level sessions key with at least 1 default session configuration for it. You can regenerate a new mongoid.yml for assistance via `rails g mongoid:config`.

Example:
development:
sessions:
default:
database: mongoid_dev
hosts:
- localhost:27017

(Mongoid::Errors::NoSessionsConfig)

问题似乎是我的 mongoid.yml 文件,如下所示:

development:
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: myapp_development
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
# Change whether the session persists in safe mode by default.
# (default: false)
# safe: false

# Change the default consistency model to :eventual or :strong.
# :eventual will send reads to secondaries, :strong sends everything
# to master. (default: :eventual)
# consistency: :eventual

# How many times Moped should attempt to retry an operation after
# failure. (default: 30)
# max_retries: 30

# The time in seconds that Moped should wait before retrying an
# operation on failure. (default: 1)
# retry_interval: 1
# Configure Mongoid specific options. (optional)
options:
# Enable the identity map, needed for eager loading. (default: false)
# identity_map_enabled: false

# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false

# Include the _type field in serializaion. (default: false)
# include_type_for_serialization: false

# Preload all models in development, needed when models use
# inheritance. (default: false)
# preload_models: false

# Protect id and type from mass assignment. (default: true)
# protect_sensitive_fields: true

# Raise an error when performing a #find and the document is not found.
# (default: true)
# raise_not_found_error: true

# Raise an error when defining a scope with the same name as an
# existing method. (default: false)
# scope_overwrite_exception: false

# Skip the database version check, used when connecting to a db without
# admin access. (default: false)
# skip_version_check: false

# Use Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true

# Ensure all times are UTC in the app side. (default: false)
# use_utc: false
test:
sessions:
default:
database: myapp_test
hosts:
- localhost:27017
options:
consistency: :strong
# In the test environment we lower the retries and retry interval to
# low amounts for fast failures.
max_retries: 1
retry_interval: 0

这个问题通常是如何解决的?提前致谢

最佳答案

Passenger作为部署工具,默认运行在生产环境。

您的 mongoid.yml 文件目前仅包含用于开发和测试的设置。您需要为生产添加配置。

类似于:

production:
sessions:
default:
database: myapp_production
hosts:
- localhost

关于mongodb - 如何将 rails + mongodb 应用程序部署到实际域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18903142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com