0

奇怪的是:bundler 正在暂存,而 rails 应用程序正在开发中。

在本地开发中工作并调用“bundle exec rake db:migrate”时,bundler 在暂存而不是开发中运行。

今天在进行新迁移时首次发现问题: bundle exec rake db:migrate

Bundler 无法连接到数据库,直到我修改了 database.yml,将暂存数据库更改为与开发数据库相同。

这个应用程序已经三个月了,并且一直在工作。今天才开始。

正在开发中的 Rails 应用程序

导轨

=> Booting Thin
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop

在启动服务器时从 newrelic_agent.log:rails s

[08/25/13 17:20:51 (1648)] INFO : Starting the New Relic agent in "development" environment.
[08/25/13 17:20:51 (1648)] INFO : To prevent agent startup add a NEWRELIC_ENABLE=false environment variable or modify the "development" section of your newrelic.yml.
[08/25/13 17:20:51 (1648)] INFO : Reading configuration from config/newrelic.yml
[08/25/13 17:20:51 (1648)] INFO : Environment: development
[08/25/13 17:20:51 (1648)] INFO : Dispatcher: thin
[08/25/13 17:20:51 (1648)] INFO : Application: Launch More (Development)
[08/25/13 17:20:51 (1648)] WARN : Agent configured not to send data in this environment.
[08/25/13 17:20:51 (1648)] INFO : Installing DelayedJob instrumentation hooks
[08/25/13 17:20:51 (1648)] INFO : Installing ActiveRecord instrumentation
[08/25/13 17:20:51 (1648)] INFO : Installing DelayedJob instrumentation
[08/25/13 17:20:51 (1648)] INFO : Installing Dalli Memcache instrumentation
[08/25/13 17:20:51 (1648)] INFO : Installing Net instrumentation
[08/25/13 17:20:51 (1648)] INFO : Installing Sinatra instrumentation
[08/25/13 17:20:51 (1648)] INFO : Installing Rails 3 Controller instrumentation
[08/25/13 17:20:51 (1648)] INFO : Installing Rails 3.1/3.2 view instrumentation
[08/25/13 17:20:51 (1648)] INFO : Installing Rails3 Error instrumentation
[08/25/13 17:20:51 (1648)] INFO : Finished instrumentation
[08/25/13 17:20:51 (1648)] INFO : NewRelic::Agent::Samplers::DelayedJobSampler sampler not available: No DJ worker present
[08/25/13 17:20:53 (1648)] INFO : Starting the New Relic agent in "development" environment.
[08/25/13 17:20:53 (1648)] INFO : To prevent agent startup add a NEWRELIC_ENABLE=false environment variable or modify the "development" section of your newrelic.yml.
[08/25/13 17:20:53 (1648)] INFO : Reading configuration from config/newrelic.yml

从 newrelic_agent.log 调用:bundle exec rake db:migrate

[08/25/13 17:23:05 (1659)] INFO : Starting the New Relic agent in "staging" environment.
[08/25/13 17:23:05 (1659)] INFO : To prevent agent startup add a NEWRELIC_ENABLE=false environment variable or modify the "staging" section of your newrelic.yml.
[08/25/13 17:23:05 (1659)] INFO : Reading configuration from config/newrelic.yml
[08/25/13 17:23:05 (1659)] WARN : Agent is configured not to use SSL when communicating with New Relic's servers
[08/25/13 17:23:05 (1659)] INFO : Environment: staging
[08/25/13 17:23:05 (1659)] INFO : Dispatcher: thin
[08/25/13 17:23:05 (1659)] INFO : Application: Launch More (Staging)
[08/25/13 17:23:05 (1659)] INFO : Installing DelayedJob instrumentation hooks
[08/25/13 17:23:05 (1659)] INFO : Installing ActiveRecord instrumentation
[08/25/13 17:23:05 (1659)] INFO : Installing DelayedJob instrumentation
[08/25/13 17:23:05 (1659)] INFO : Installing Dalli Memcache instrumentation
[08/25/13 17:23:05 (1659)] INFO : Installing Net instrumentation
[08/25/13 17:23:05 (1659)] INFO : Installing Sinatra instrumentation
[08/25/13 17:23:05 (1659)] INFO : Installing Rails 3 Controller instrumentation
[08/25/13 17:23:05 (1659)] INFO : Installing Rails 3.1/3.2 view instrumentation
[08/25/13 17:23:05 (1659)] INFO : Installing Rails3 Error instrumentation
[08/25/13 17:23:05 (1659)] INFO : Finished instrumentation
[08/25/13 17:23:05 (1659)] INFO : NewRelic::Agent::Samplers::DelayedJobSampler sampler not available: No DJ worker present
[08/25/13 17:23:06 (1659)] INFO : Starting the New Relic agent in "staging" environment.
[08/25/13 17:23:07 (1659)] INFO : To prevent agent startup add a NEWRELIC_ENABLE=false environment variable or modify the "staging" section of your newrelic.yml.
[08/25/13 17:23:07 (1659)] INFO : Reading configuration from config/newrelic.yml

关于为什么的任何想法?

如何解决这个问题?

谢谢,马克

~~~~~~~~~~~~~~~~~~~~~~~~~

ruby 1.9.3p202(2012-04-27 修订版 35484)[x86_64-darwin10.8.0]

4

2 回答 2

0

好的 - 如此愚蠢的举动 - 但一次很棒的学习体验!

ISSUE: 每当 gem & Cronjob

在设置when gem 以在不同环境中调用不同的cron 作业时,我遇到了问题。

在 development 和 staging 中查看 cronjob 你可以运行:

捆绑执行无论何时

但是在两个环境中运行“bundle exec 时”显示“RAILS_ENV=production”。

因此,为了在分段和开发中解决这个“RAILS_ENV=production”,我设置了单独的 cron 作业:

sitemap.rb sitemap_staging.rb

...然后在 sitemap_stageing.rb 中包括:

Rails.env = '暂存'

...我在想“Rails.env = 'staging'”只会在需要时被调用。

经验教训...启动应用程序时,正在调用“Rails.env = 'staging'”并设置环境。呸!

当我运行“crontab -e”时,它显示了适合开发、登台和生产的环境:

当运行“bundle execwhen”时,它只显示“RAILS_ENV=production”——很奇怪。

谢谢,马克

于 2013-08-28T03:41:03.327 回答
0

第一:你应该有某种源代码控制。有什么改变吗?回顾最近一次成功地允许你做你想做的事情的提交。

接下来,我将检查您是否设置了任何环境变量,专门告诉它以暂存模式 (RAILS_ENV) 运行。还要检查你的 new_relic.yml 文件。

最后,如果这两个都是负面的,我会进一步研究您的主机配置。他们是否为您的环境部署了一些更新?

于 2013-08-25T20:24:49.103 回答