diff --git a/config/app_config.yml.example b/config/app_config.yml.example index 393b6e53d..243dddf87 100644 --- a/config/app_config.yml.example +++ b/config/app_config.yml.example @@ -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 # the COPYRIGHT file. @@ -99,13 +99,28 @@ default: # Process jobs in process? single_process_mode: true +# Use this sections to overide settings from default in the specific environments development: enable_splunk_logging: false +production: + single_process_mode: false + +# Do not touch unless you know what you're doing test: pod_url: "http://example.org/" socket_port: 8081 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" + diff --git a/config/server.sh b/config/server.sh deleted file mode 100644 index 7060a9f5c..000000000 --- a/config/server.sh +++ /dev/null @@ -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' diff --git a/lib/app_config.rb b/lib/app_config.rb index 53ad6de8c..77f1ef101 100644 --- a/lib/app_config.rb +++ b/lib/app_config.rb @@ -27,14 +27,19 @@ class AppConfig end 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" - all_envs = 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_custom = load_config_yaml "#{Rails.root}/config/app_config.yml" + all_envs.merge!(all_envs_custom) else 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." end - all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example" end env = env.to_s diff --git a/script/get_config.rb b/script/get_config.rb index 1f0067965..fe0449297 100755 --- a/script/get_config.rb +++ b/script/get_config.rb @@ -35,8 +35,8 @@ if ARGV.length >= 1 exit 2 end else - puts "Usage: ./script/get_config.rb option [environment]" + puts "Usage: ./script/get_config.rb option [section]" puts "" - puts "envrionment defaults to development" + puts "section defaults to development" exit 1 end diff --git a/script/server b/script/server index 714cb8177..6122f1642 100755 --- a/script/server +++ b/script/server @@ -8,9 +8,13 @@ cd $( dirname $realpath)/.. 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 # Create all dynamically generated files in public/ folder