Module: Lux::Config
Instance Method Summary collapse
- #app_timeout ⇒ Object
-
#load ⇒ Object
‘./config/secrets.yaml’ default: development: foo: production: foo:.
- #ram ⇒ Object
- #set_defaults ⇒ Object
- #start_info ⇒ Object
Instance Method Details
#app_timeout ⇒ Object
69 70 71 72 73 |
# File 'lib/lux/config/config.rb', line 69 def app_timeout @app_timeout ||= Lux.current.try('[]', :app_timeout) || Lux.config[:app_timeout] || (Lux.env.dev? ? 3600 : 30) rescue 30 end |
#load ⇒ Object
‘./config/secrets.yaml’ default:
development:
foo:
production:
foo:
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/lux/config/config.rb', line 81 def load source = Pathname.new './config/config.yaml' if source.exist? data = YAML.safe_load source.read, aliases: true base = data['default'] || data['base'] if base base.deep_merge!(data[Lux.env.to_s] || {}) base['production'] = data['production'] base else raise "Secrets :default root not defined in %s" % source end else puts Lux.info '%s not found' % source {} end end |
#ram ⇒ Object
8 9 10 |
# File 'lib/lux/config/config.rb', line 8 def ram `ps -o rss -p #{$$}`.chomp.split("\n").last.to_i / 1000 end |
#set_defaults ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/lux/config/config.rb', line 39 def set_defaults ENV['LUX_ENV'] ||= '' ENV['TZ'] ||= 'UTC' # Delay Lux.config.delay_timeout = Lux.env.dev? ? 3600 : 30 # Logger Lux.config.logger_path_mask = './log/%s.log' Lux.config.logger_files_to_keep = 3 Lux.config.logger_file_max_size = 10_240_000 Lux.config.logger_formatter = nil # Other Lux.config.use_autoroutes = false Lux.config.asset_root = false Lux.config[:plugins] ||= [] Lux.config[:error_logger] ||= Proc.new do |error| ap [error., error.class, Lux::Error.mark_backtrace(error)] end ### # Serve static files is on by default Lux.config.serve_static_files = true # Etag and cache tags reset after deploy Lux.config. = File.mtime('./Gemfile').to_i.to_s end |
#start_info ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lux/config/config.rb', line 12 def start_info @load_info ||= proc do info = [] config = [] %w(no_cache reload_code show_errors screen_log).each do |name| value = Lux.env.send("#{name}?") config.push value ? "#{name} (yes)".yellow : "#{name} (no)".green end info.push "Lux env: #{config.join(', ')}" if $lux_start_time.class == Array # $lux_start_time ||= Time.now added to Gemfile speed = 'in %s sec (%s gems, %s app)' % [ time_diff($lux_start_time[0]).white, time_diff($lux_start_time[0], $lux_start_time[1]), time_diff($lux_start_time[1]), ] else speed = 'in %s sec' % time_diff($lux_start_time).white end info.push "* Lux loaded in #{ENV['RACK_ENV']} mode, #{speed}, uses #{ram.to_s.white} MB RAM with total of #{Gem.loaded_specs.keys.length.to_s.white} gems in spec" info.join($/) end.call end |