diff --git a/config/server.sh b/config/server.sh index 7398b2fd8..64d989275 100644 --- a/config/server.sh +++ b/config/server.sh @@ -2,11 +2,10 @@ # Included by script/server # THIN_PORT=3000 -SOCKET_PORT=8080 # Choose one mode by uncommenting export RAILS_ENV='development' -#export RAILS_ENV='production' +export RAILS_ENV='production' # See thin -h for possible values. DEFAULT_THIN_ARGS="-p $THIN_PORT -e $RAILS_ENV" diff --git a/lib/app_config.rb b/lib/app_config.rb index 7fefcf93d..53ad6de8c 100644 --- a/lib/app_config.rb +++ b/lib/app_config.rb @@ -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. @@ -14,6 +14,10 @@ class AppConfig config_vars[key] = value end + def self.has_key?(key) + config_vars.has_key?(key) + end + def self.configure_for_environment(env) load_config_for_environment(env) generate_pod_uri diff --git a/script/get_config.rb b/script/get_config.rb new file mode 100755 index 000000000..1f0067965 --- /dev/null +++ b/script/get_config.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby +# Copyright (c) 2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'rubygems' +require 'yaml' + +require 'active_support/core_ext/class/attribute_accessors' +require 'active_support/core_ext/hash/keys' + +class Rails + def self.root + File.join(File.dirname(__FILE__), "..") + end + + def self.env + env = 'development' + env = ENV['RAILS_ENV'] if ENV.has_key?('RAILS_ENV') + env = ARGV[1] if ARGV.length == 2 + env.downcase + end +end + +require File.join(Rails.root, 'lib', 'app_config') + + +if ARGV.length >= 1 + key = ARGV[0].to_sym + AppConfig.configure_for_environment(Rails.env) + if AppConfig.has_key?(key) + print AppConfig[key] + else + puts "Invalid option #{ARGV[0]}" + exit 2 + end +else + puts "Usage: ./script/get_config.rb option [environment]" + puts "" + puts "envrionment defaults to development" + exit 1 +end diff --git a/script/server b/script/server index d94da6d15..8b6270b75 100755 --- a/script/server +++ b/script/server @@ -10,6 +10,7 @@ OS=`uname -s` [ -e config/server.sh ] && source config/server.sh +export SOCKET_PORT=$(./script/get_config.rb socket_port $RAILS_ENV) function init_public # Create all dynamically generated files in public/ folder @@ -169,6 +170,8 @@ fi mkdir -p -v log/thin/ bundle exec ruby ./script/websocket_server.rb& -redis-server config/redis.conf &>log/redis-console.log & -QUEUE=* bundle exec rake resque:work& +if [ "$(./script/get_config.rb single_process_mode $RAILS_ENV)" = "false" ]; then + redis-server config/redis.conf &>log/redis-console.log & + QUEUE=* bundle exec rake resque:work& +fi bundle exec thin start $args