"Fossies" - the Fresh Open Source Software Archive 
Member "discourse-2.8.3/config/initializers/000-development_reload_warnings.rb" (14 Apr 2022, 1331 Bytes) of package /linux/www/discourse-2.8.3.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the last
Fossies "Diffs" side-by-side code changes report for "000-development_reload_warnings.rb":
2.7.13_vs_2.8.0.
1 # frozen_string_literal: true
2
3 # Development helper which prints a warning when you edit a non-autoloaded ruby file.
4 # These include initializers, middleware, plugin.rb files, and more.
5 # Launch the server with AUTO_RESTART=0 to disable automatic restarts.
6 if Rails.env.development? && !Rails.configuration.cache_classes && Discourse.running_in_rack?
7 paths = [
8 *Dir["#{Rails.root}/app/*"].reject { |path| path.end_with? "/assets" },
9 "#{Rails.root}/config",
10 "#{Rails.root}/lib",
11 "#{Rails.root}/plugins"
12 ]
13
14 Listen.to(*paths, only: /\.rb$/) do |modified, added, removed|
15 supervisor_pid = UNICORN_DEV_SUPERVISOR_PID
16 auto_restart = supervisor_pid && ENV["AUTO_RESTART"] != "0"
17
18 files = modified + added + removed
19
20 not_autoloaded = files.filter_map do |file|
21 autoloaded = Rails.autoloaders.main.autoloads.key? file
22 Pathname.new(file).relative_path_from(Rails.root) if !autoloaded
23 end
24
25 if not_autoloaded.length > 0
26 message = auto_restart ? "Restarting server..." : "Server restart required. Automate this by setting AUTO_RESTART=1."
27 STDERR.puts "[DEV]: Edited files which are not autoloaded. #{message}"
28 STDERR.puts not_autoloaded.map { |path| "- #{path}".indent(7) }.join("\n")
29 Process.kill("USR2", supervisor_pid) if auto_restart
30 end
31 end.start
32 end