lib/karafka/railtie.rb in karafka-2.0.0.alpha5 vs lib/karafka/railtie.rb in karafka-2.0.0.alpha6
- old
+ new
@@ -80,10 +80,22 @@
end
initializer 'karafka.require_karafka_boot_file' do |app|
rails6plus = Rails.gem_version >= Gem::Version.new('6.0.0')
+ # If the boot file location is set to "false", we should not raise an exception and we
+ # should just not load karafka stuff. Setting this explicitly to false indicates, that
+ # karafka is part of the supply chain but it is not a first class citizen of a given
+ # system (may be just a dependency of a dependency), thus railtie should not kick in to
+ # load the non-existing boot file
+ next if Karafka.boot_file.to_s == 'false'
+
karafka_boot_file = Rails.root.join(Karafka.boot_file.to_s).to_s
+
+ # Provide more comprehensive error for when no boot file
+ unless File.exist?(karafka_boot_file)
+ raise(Karafka::Errors::MissingBootFileError, karafka_boot_file)
+ end
if rails6plus
app.reloader.to_prepare do
# Load Karafka boot file, so it can be used in Rails server context
require karafka_boot_file