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:
parent
a3c287ca9a
commit
e79a6597e6
5 changed files with 34 additions and 25 deletions
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue