简体   繁体   English

Rails 不检测文件更改并且 config.reload_classes_only_on_change 使服务器太慢

[英]Rails doesn't detect file changes and config.reload_classes_only_on_change makes the server too slow

First of all I don't know if this is a bug or not.首先我不知道这是否是一个错误。 Until now I've been using this command in rails development.rb environment config so the box detects changes on my files:到目前为止,我一直在 rails development.rb 环境配置中使用此命令,因此该框可以检测到我的文件的更改:

config.reload_classes_only_on_change = false

But now, with Rails 5.2 and Active Storage that command makes the server a lot slower, and the images takes from 10 to 40sec to load.但是现在,使用 Rails 5.2 和 Active Storage,该命令会使服务器速度变慢,加载图像需要 10 到 40 秒。

Is it a bug?它是一个错误吗? There is another way to make the vagrant/rails detect changes on my files without making me reload the server every time I change something?还有另一种方法可以让 vagrant/rails 检测到我的文件上的更改,而无需每次更改某些内容时都让我重新加载服务器?

Solution:解决方案:

After questioning the owner of the box I've been using, he gave me this alternative that works:在询问了我一直在使用的盒子的主人之后,他给了我这个可行的替代方案:

At the bottom of the config/environments/development.rb I did this change:config/environments/development.rb我做了这个改变的底部:

Find this line at the bottom of the file and comment out:在文件底部找到这一行并注释掉:

config.file_watcher = ActiveSupport::EventedFileUpdateChecker

Then add this line:然后添加这一行:

config.file_watcher = ActiveSupport::FileUpdateChecker

So it looks like this:所以它看起来像这样:

# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.file_watcher = ActiveSupport::FileUpdateChecker

Now it works properly and I do not have to use this command anymore:现在它可以正常工作了,我不必再使用这个命令了:

config.reload_classes_only_on_change = true

Best regards!此致!

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

相关问题 Rails 服务器看不到代码更改并重新加载文件 - Rails server doesn't see code changes and reload files Rails 生产服务器 config.cache_classes = true 不会为活动作业正确重新加载自定义服务类 - Rails production server config.cache_classes = true does not reload custom service classes correctly for active job Rails自己的配置/初始化程序已更新,并且不显示更改 - Rails own config/initializers updated and doesn't display changes Rails 4不检测应用程序 - Rails 4 doesn't detect application rails3加载我的基类,但是在代码更改时不评估我的子类 - rails3 loads my base class but doesn't evaluate my sub-classes when code changes RSpec:重新打开类时,存根Rails.application.config值不起作用? - RSpec: stubbing Rails.application.config value doesn't work when reopening classes? Helper方法不会在Rails控制台中通过`reload!`重新加载 - Helper method doesn't reload by `reload!` in rails console 带“#{}”的Coffeescript使rails变得如此缓慢 - Coffeescript with “#{}” makes rails so slow 使用多个时,Rails文件字段不会更改名称 - Rails file field doesn't change the name when using multiple Ruby on Rails在服务器运行时配置更改? - Ruby on Rails config change while server is running?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM