eliminate config/server.sh; use config/app_config.yml.example as base for configuration, config/app_config.yml is now just an overider. This way we can add new configuration options without checking in the application if it's set and the user has to update his app_config.yml only when he want to change something

This commit is contained in:
MrZYX 2011-05-18 16:11:20 +02:00
parent a3c287ca9a
commit e79a6597e6
5 changed files with 34 additions and 25 deletions

View file

@ -1,4 +1,4 @@
# Copyright (c) 2010, Diaspora Inc. This file is # Copyright (c) 2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
@ -99,13 +99,28 @@ default:
# Process jobs in process? # Process jobs in process?
single_process_mode: true single_process_mode: true
# Use this sections to overide settings from default in the specific environments
development: development:
enable_splunk_logging: false enable_splunk_logging: false
production:
single_process_mode: false
# Do not touch unless you know what you're doing
test: test:
pod_url: "http://example.org/" pod_url: "http://example.org/"
socket_port: 8081 socket_port: 8081
enable_splunk_logging: false enable_splunk_logging: false
production:
single_process_mode: false # This section is special, you cannot overide settings from here in the above sections
script_server:
# Port on which thin should listen
thin_port: 3000
# customize thins startup
default_thin_args: "-p $THIN_PORT -e $RAILS_ENV"
# Possibilties are development, production
rails_env: "development"

View file

@ -1,15 +0,0 @@
#
# Included by script/server
#
THIN_PORT=3000
# Choose one mode by uncommenting
export RAILS_ENV='development'
#export RAILS_ENV='production'
# See thin -h for possible values.
DEFAULT_THIN_ARGS="-p $THIN_PORT -e $RAILS_ENV"
# Set to 'no' to disable server dry-run at first start
# creating generated files in public/ folder.
#INIT_PUBLIC='no'

View file

@ -27,14 +27,19 @@ class AppConfig
end end
def self.load_config_for_environment(env) def self.load_config_for_environment(env)
if File.exist? "#{Rails.root}/config/app_config.yml.example"
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example"
else
$stderr.puts "ERROR: Why have you deleted config/app_config.yml.example?"
all_envs = {}
end
if File.exist? "#{Rails.root}/config/app_config.yml" if File.exist? "#{Rails.root}/config/app_config.yml"
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml" all_envs_custom = load_config_yaml "#{Rails.root}/config/app_config.yml"
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example" unless all_envs all_envs.merge!(all_envs_custom)
else else
unless Rails.env == "development" || Rails.env == "test" unless Rails.env == "development" || Rails.env == "test"
$stderr.puts "WARNING: No config/app_config.yml found! Look at config/app_config.yml.example for help." $stderr.puts "WARNING: No config/app_config.yml found! Look at config/app_config.yml.example for help."
end end
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example"
end end
env = env.to_s env = env.to_s

View file

@ -35,8 +35,8 @@ if ARGV.length >= 1
exit 2 exit 2
end end
else else
puts "Usage: ./script/get_config.rb option [environment]" puts "Usage: ./script/get_config.rb option [section]"
puts "" puts ""
puts "envrionment defaults to development" puts "section defaults to development"
exit 1 exit 1
end end

View file

@ -8,9 +8,13 @@ cd $( dirname $realpath)/..
OS=`uname -s` OS=`uname -s`
[ -e config/server.sh ] && source config/server.sh export RAILS_ENV=$(./script/get_config.rb rails_env script_server)
THIN_PORT=$(./script/get_config.rb thin_port script_server)
eval "DEFAULT_THIN_ARGS=\"$(./script/get_config.rb default_thin_args script_server)\""
SOCKET_PORT=$(./script/get_config.rb socket_port $RAILS_ENV)
export SOCKET_PORT=$(./script/get_config.rb socket_port $RAILS_ENV) # Backward compatibillity, overide default settings
[ -e config/server.sh ] && source config/server.sh
function init_public function init_public
# Create all dynamically generated files in public/ folder # Create all dynamically generated files in public/ folder