Module: Bridgetown::Rack
- Defined in:
- lib/bridgetown-core/rack/boot.rb,
lib/bridgetown-core/rack/logger.rb,
lib/bridgetown-core/rack/routes.rb
Defined Under Namespace
Class Attribute Summary collapse
-
.interrupted ⇒ Object
Returns the value of attribute interrupted.
- .loaders_manager ⇒ Bridgetown::Utils::LoadersManager
Class Method Summary collapse
- .autoload_server_folder(root: Bridgetown::Current.preloaded_configuration.root_dir) ⇒ Object
-
.boot ⇒ Object
Start up the Roda Rack application and the Zeitwerk autoloaders.
Class Attribute Details
.interrupted ⇒ Object
Returns the value of attribute interrupted.
8 9 10 |
# File 'lib/bridgetown-core/rack/routes.rb', line 8 def interrupted @interrupted end |
.loaders_manager ⇒ Bridgetown::Utils::LoadersManager
29 30 31 |
# File 'lib/bridgetown-core/rack/boot.rb', line 29 def loaders_manager @loaders_manager end |
Class Method Details
.autoload_server_folder(root: Bridgetown::Current.preloaded_configuration.root_dir) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/bridgetown-core/rack/boot.rb', line 51 def self.autoload_server_folder( # rubocop:todo Metrics root: Bridgetown::Current.preloaded_configuration.root_dir ) server_folder = File.join(root, "server") Bridgetown::Hooks.register_one( :loader, :post_setup, reloadable: false ) do |loader, load_path| next unless load_path == server_folder loader.eager_load loader.do_not_eager_load(File.join(server_folder, "roda_app.rb")) unless ENV["BRIDGETOWN_ENV"] == "production" Listen.to(server_folder) do |modified, added, removed| c = modified + added + removed n = c.length Bridgetown.logger.info( "Reloading…", "#{n} file#{"s" if n > 1} changed at #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}" ) c.each do |path| Bridgetown.logger.info "", "- #{path["#{File.dirname(server_folder)}/".length..]}" end loader.reload loader.eager_load Bridgetown::Rack::Routes.reload_subclasses rescue SyntaxError => e Bridgetown::Errors.print_build_error(e) end.start end end Bridgetown::Hooks.register_one( :loader, :post_reload, reloadable: false ) do |loader, load_path| next unless load_path == server_folder loader.eager_load Bridgetown::Rack::Routes.reload_subclasses end loaders_manager.setup_loaders([server_folder]) end |
.boot ⇒ Object
Start up the Roda Rack application and the Zeitwerk autoloaders. Ensure the Roda app is provided the preloaded Bridgetown site configuration. Handle any uncaught Roda errors.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bridgetown-core/rack/boot.rb', line 35 def self.boot(*) self.loaders_manager = Bridgetown::Utils::LoadersManager.new(Bridgetown::Current.preloaded_configuration) Bridgetown::Current.preloaded_configuration.run_initializers! context: :server autoload_server_folder rescue Roda::RodaError => e if e..include?("sessions plugin :secret option") raise Bridgetown::Errors::InvalidConfigurationError, "The Roda sessions plugin can't find a valid secret. Run `bin/bridgetown secret' " \ "and put the key in a ENV var you can use to configure the session in the Roda app" end raise e end |