class Rage::Configuration
- RAGE_DISABLE_AR_WEAK_CONNECTIONS - instructs Rage to not reuse Active Record connections between different fibers. Only applies to Active Record < 7.2.
- RAGE_DISABLE_AR_POOL_PATCH - disables the ‘ActiveRecord::ConnectionPool` patch and makes Rage use the original ActiveRecord implementation.
- RAGE_DISABLE_IO_WRITE - disables the `io_write` hook to fix the [“zero-length iov”](bugs.ruby-lang.org/issues/19640) error on Ruby < 3.3.
The settings described in this section should be configured using **environment variables** and are either temporary or will become the default in the future.
## Transient Settings
“`
end
config.server.port = 8080
config.log_level = :warn
Rage.configure do
“`ruby
Example:
Use {Rage.configure Rage.configure} to access and modify the configuration.
Configuration class for Rage framework.
#
def __finalize
- Private: -
def __finalize if @logger @logger.formatter = @log_formatter if @log_formatter @logger.level = @log_level if @log_level else @logger = Rage::Logger.new(nil) end if @log_formatter && @logger.external_logger.is_a?(Rage::Logger::External::Dynamic) puts "WARNING: changing the log formatter via `config.log_formatter=` has no effect when using a custom external logger." end if @log_context Rage.__log_processor.add_custom_context(@log_context.objects) @logger.dynamic_context = Rage.__log_processor.dynamic_context end if @log_tags Rage.__log_processor.add_custom_tags(@log_tags.objects) @logger.dynamic_tags = Rage.__log_processor.dynamic_tags end if defined?(::Rack::Events) && middleware.include?(::Rack::Events) middleware.delete(Rage::BodyFinalizer) middleware.insert_before(::Rack::Events, Rage::BodyFinalizer) end Rage::Telemetry.__setup if @telemetry end
def after_initialize(&block)
SUPER_USER = User.find_by!(super: true)
Rage.config.after_initialize do
@example
Schedule a block of code to run after Rage has finished loading the application code. Use this to reference application-level constants during the initialization process.
def after_initialize(&block) push_hook(block, :after_initialize) end
def cable
-
(Rage::Configuration::Cable)-
def cable @cable ||= Cable.new end
def config = self
- Private: -
def config = self
def deferred
-
(Rage::Configuration::Deferred)-
def deferred @deferred ||= Deferred.new end
def fallback_secret_key_base
-
(Array-)
def fallback_secret_key_base Array(@fallback_secret_key_base || ENV["FALLBACK_SECRET_KEY_BASE"]) end
def fallback_secret_key_base=(key)
-
key(String, Array) -- the fallback secret key base(s)
def fallback_secret_key_base=(key) @fallback_secret_key_base = key end
def internal
- Private: -
def internal @internal ||= Internal.new end
def log_context
-
(Rage::Configuration::LogContext)-
def log_context @log_context ||= LogContext.new end
def log_formatter
-
(#call, nil)-
def log_formatter @log_formatter end
def log_formatter=(formatter)
-
formatter(#call) -- a callable object that formats log messages
def log_formatter=(formatter) raise ArgumentError, "Custom log formatter should respond to `#call`" unless formatter.respond_to?(:call) @log_formatter = formatter end
def log_level
-
(Integer, nil)-
def log_level @log_level end
def log_level=(level)
-
level(:debug, :info, :warn, :error, :fatal, :unknown, Integer) -- the log level
def log_level=(level) @log_level = level.is_a?(Symbol) ? Logger.const_get(level.to_s.upcase) : level end
def log_tags
-
(Rage::Configuration::LogTags)-
def log_tags @log_tags ||= LogTags.new end
def logger
-
(Rage::Logger, nil)-
def logger @logger end
def logger=(logger)
-
logger=(nil) -
logger=(callable) -
logger=(logger)
Parameters:
-
callable(ExternalLoggerInterface) -- -
logger(#debug, #info, #warn, #error, #fatal, #unknown) --
def logger=(logger) @logger = if logger.nil? || logger.is_a?(Rage::Logger) logger elsif Rage::Logger::METHODS_MAP.keys.all? { |method| logger.respond_to?(method) } Rage::Logger.new(Rage::Logger::External::Static[logger]) elsif logger.respond_to?(:call) Rage::Logger.new(Rage::Logger::External::Dynamic[logger]) else raise ArgumentError, "Invalid logger: must be an instance of `Rage::Logger`, respond to `#call`, or implement all standard Ruby Logger methods (`#debug`, `#info`, `#warn`, `#error`, `#fatal`, `#unknown`)" end end
def middleware
-
(Rage::Configuration::Middleware)-
def middleware @middleware ||= Middleware.new end
def openapi
-
(Rage::Configuration::OpenAPI)-
def openapi @openapi ||= OpenAPI.new end
def public_file_server
-
(Rage::Configuration::PublicFileServer)-
def public_file_server @public_file_server ||= PublicFileServer.new end
def run_after_initialize!
- Private: -
def run_after_initialize! run_hooks_for!(:after_initialize, self) __finalize end
def secret_key_base
-
(String, nil)-
def secret_key_base @secret_key_base || ENV["SECRET_KEY_BASE"] end
def secret_key_base=(key)
-
key(String) -- the secret key base
def secret_key_base=(key) @secret_key_base = key end
def server
-
(Rage::Configuration::Server)-
def server @server ||= Server.new end
def session
-
(Rage::Configuration::Session)-
def session @session ||= Session.new end
def telemetry
-
(Rage::Configuration::Telemetry)-
def telemetry @telemetry ||= Telemetry.new end