Skip to content

A platform for community discussion. Free, open, simple.

DEV: Skip unnecessary work when booting dev server on linux (#28401)

David Taylore8308f783dce
diff --git a/config/initializers/000-development_reload_warnings.rb b/config/initializers/000-development_reload_warnings.rb
index bc7acc57851..fa93c8ff5a5 100644
--- a/config/initializers/000-development_reload_warnings.rb
+++ b/config/initializers/000-development_reload_warnings.rb
@@ -11,6 +11,21 @@ if Rails.env.development? && !Rails.configuration.cache_classes && Discourse.run
"#{Rails.root}/plugins",
]
+ if Listen::Adapter::Linux.usable?
+ # The Listen gem watches recursively, which has a cost per-file on Linux (via rb-inotify)
+ # Skip a bunch of unnecessary directories to reduce the cost
+ # Ref https://github.com/guard/listen/issues/556
+ require "rb-inotify"
+ INotify::Notifier.prepend(
+ Module.new do
+ def watch(path, *flags, &callback)
+ return if path.end_with?("/node_modules", "/.git")
+ super(path, *flags, &callback)
+ end
+ end,
+ )
+ end
+
Listen
.to(*paths, only: /\.rb$/) do |modified, added, removed|
supervisor_pid = UNICORN_DEV_SUPERVISOR_PID