如何在一台服务器上运行mongodb数据库进行生产和开发?

时间:2013-10-14 15:19:54

标签: ruby-on-rails mongodb passenger development-environment production-environment

我有两个(相同的)rails应用程序和nginx配置(与乘客一起使用):

> cat ./sites-available/app-production

server {
  listen 80;
  server_name app-development.mydomain.com;
  root /path/to/my/production/app/public;
  passenger_enabled on;
  rails_env production;
}

> cat ./sites-available/app-development

server {
  listen 80;
  server_name app-development.mydomain.com;
  root /path/to/my/development/app/public;
  passenger_enabled on;
  rails_env development;
}

两者都有./config/mongoid.yml:

development:
  sessions:
    default:
      database: app-development
      hosts:
        - localhost:27017
      options:
        consistency: :strong
  options:

production:
  sessions:
    default:
      database: app-production
      hosts:
        - localhost:27017
      options:
        consistency: :strong
  options:

但如果我同时启动它们,我会看到它们使用相同的数据库:我在development中更改了一些数据,我也看到了production中的更改。

如果这些配置还不够,还有哪些其他配置。或者我做错了什么?

更新

实际上我不知道应用程序是否在不同的环境中运行。如果我停止mongodb,则两者都会呈现调试(错误)视图。看起来他们都在运行开发。如何强迫乘客运行不同的环境?我认为这项工作是通过设置rails_env参数

来完成的

更新2:

所以,如果我查看mongo

> show dbs

  app-development    0.203125GB
  local (empty)

因此,未创建生产数据库。

更新3:

我也执行了:

rake db:create RAILS_ENV=production

在我的生产rails应用程序中,但仍无效果。

更新4:

这里提议Can't force Rails into production environment via Passenger/Nginx我删除了config.ru,但后来我从Phusion Passenger收到错误:

This application is a Rails 4 application, but it was wrongly detected as a Rails 1 or Rails 2 application. This is probably a bug in Phusion Passenger, so please report it.

更新5:

现在(在我返回config.ru之后)它变得更糟 - 来自Phusion Passenger的错误:

https://github.com/mongoid/mongoid.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)

我做bundle install但没有效果。

更新6:

从这里is not checked out... bundle install does NOT fix help!

bundle install --deployment

现在安装所有宝石。暂时没有Phusion Passenger错误,但我现在收到来自rails的错误:

Permission denied - /path/to/my_rails_app/tmp/cache/assets/development/sprockets/37b5a12047376b10a57191a10d3af30a rails error

我在./tmp/

后面没有这样的文件/文件夹

更新7:

听起来像Permission denied in tmp中的类似问题。但我不知道应该申请哪个chown user:group?我有Phusion Passengernginx

如果我执行:

> sudo chown -R http:http ~/project/my_app/

我明白了:

chown: invalid user: `http:http'

0 个答案:

没有答案