diff --git a/app/models/app_config.rb b/app/models/app_config.rb index 7786c166c..11a4ef9b3 100644 --- a/app/models/app_config.rb +++ b/app/models/app_config.rb @@ -132,4 +132,8 @@ HELP end return @@pod_uri end + + def self.single_process_mode? + (ENV['SINGLE_PROCESS'] == "true" || ENV['SINGLE_PROCESS_MODE'] == "true" || self[:single_process_mode]) ? true : false + end end diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index 2aa64a11c..0c9f7d2fc 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -2,7 +2,7 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. --if ENV['SINGLE_PROCESS'] +-if AppConfig.single_process_mode? :javascript var websocket_enabled = false - else diff --git a/config/initializers/resque.rb b/config/initializers/resque.rb index af6f820b8..81ffaeb5a 100644 --- a/config/initializers/resque.rb +++ b/config/initializers/resque.rb @@ -6,7 +6,7 @@ if !ENV['SINGLE_PROCESS'] && AppConfig[:redis_url] Resque.redis = Redis.new(:host => AppConfig[:redis_url], :port => 6379) end -if ENV['SINGLE_PROCESS'] || AppConfig.single_process_mode +if AppConfig.single_process_mode? if Rails.env == 'production' puts "WARNING: You are running Diaspora in production without Resque workers turned on. Please don't do this." end diff --git a/script/get_config.rb b/script/get_config.rb index 77601fbf6..d8509c7ed 100755 --- a/script/get_config.rb +++ b/script/get_config.rb @@ -35,9 +35,11 @@ if ARGV.length >= 1 require 'settingslogic' require File.join(Rails.root, 'app', 'models', 'app_config') setting_name = setting_name.to_sym - if AppConfig[setting_name].nil? + if (!AppConfig.respond_to?(setting_name) || AppConfig.send(setting_name).nil?) && AppConfig[setting_name].nil? $stderr.puts "Could not find setting #{ARGV[0]} for environment #{Rails.env}." Process.exit(1) + elsif AppConfig.respond_to?(setting_name) + print AppConfig.send(setting_name) else print AppConfig[setting_name] end diff --git a/script/server b/script/server index 9bfc17b8d..5e1c072b2 100755 --- a/script/server +++ b/script/server @@ -153,7 +153,7 @@ fi # Start Diaspora -if [ "$SINGLE_PROCESS" != "true" ]; then +if [ "$(./script/get_config.rb 'single_process_mode?')" != "true" ]; then redis_config redis-server config/redis.conf &>log/redis-console.log &