Rework application configuration
Use a preinitializer to load the settings from application.yml so that they are available as early as possible. All settings can also be overridden using environment variables. The ad-hoc settins in environment.rb are then moved to this new system so we have one consistent location for settings.
This commit is contained in:
parent
8b9cacd3c2
commit
f07819d81a
33 changed files with 100 additions and 99 deletions
|
@ -1,4 +0,0 @@
|
|||
# This file loads various yml configuration files
|
||||
|
||||
# Load application config
|
||||
APP_CONFIG = YAML.load(File.read(RAILS_ROOT + "/config/application.yml"))[RAILS_ENV]
|
|
@ -1,11 +1,11 @@
|
|||
# Setup any specified hard limit on the virtual size of the process
|
||||
if APP_CONFIG.include?('hard_memory_limit') and Process.const_defined?(:RLIMIT_AS)
|
||||
Process.setrlimit Process::RLIMIT_AS, APP_CONFIG['hard_memory_limit']*1024*1024, Process::RLIM_INFINITY
|
||||
if defined?(HARD_MEMORY_LIMIT) and Process.const_defined?(:RLIMIT_AS)
|
||||
Process.setrlimit Process::RLIMIT_AS, HARD_MEMORY_LIMIT*1024*1024, Process::RLIM_INFINITY
|
||||
end
|
||||
|
||||
# If we're running under passenger and a soft memory limit is
|
||||
# configured then setup some rack middleware to police the limit
|
||||
if APP_CONFIG.include?('soft_memory_limit') and defined?(PhusionPassenger)
|
||||
if defined?(SOFT_MEMORY_LIMIT) and defined?(PhusionPassenger)
|
||||
# Define some rack middleware to police the soft memory limit
|
||||
class MemoryLimit
|
||||
def initialize(app)
|
||||
|
@ -17,7 +17,7 @@ if APP_CONFIG.include?('soft_memory_limit') and defined?(PhusionPassenger)
|
|||
status, headers, body = @app.call(env)
|
||||
|
||||
# Restart if we've hit our memory limit
|
||||
if resident_size > APP_CONFIG['soft_memory_limit']
|
||||
if resident_size > SOFT_MEMORY_LIMIT
|
||||
Process.kill("USR1", 0)
|
||||
end
|
||||
|
||||
|
|
|
@ -12,6 +12,6 @@ ActionController::Base.session = {
|
|||
# Use the database for sessions instead of the cookie-based default,
|
||||
# which shouldn't be used to store highly confidential information
|
||||
# (create the session table with "rake db:sessions:create")
|
||||
unless OSM_STATUS == :database_offline or OSM_STATUS == :database_readonly
|
||||
unless STATUS == :database_offline or STATUS == :database_readonly
|
||||
ActionController::Base.session_store = :sql_session_store
|
||||
end
|
||||
|
|
|
@ -4,6 +4,6 @@ adapter = Rails.configuration.database_configuration[environment]["adapter"]
|
|||
session_class = adapter + "_session"
|
||||
|
||||
# Configure SqlSessionStore
|
||||
unless OSM_STATUS == :database_offline
|
||||
unless STATUS == :database_offline
|
||||
SqlSessionStore.session_class = session_class.camelize.constantize
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue