Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonne Haß <me@mrzyx.de>2012-11-30 17:00:25 +0400
committerJonne Haß <me@mrzyx.de>2012-11-30 17:00:25 +0400
commit2a7a0b7b990b70835e336ddffe62bf0e4b198ac4 (patch)
tree8e2c85ff8d9ac6ebc1146d8332c80120028e0e76
parent669dd87b11b9b989848f5f0393037c97fb53b1ef (diff)
* made number of unicorn worker processes configurable
* made configuration loader indepenent of rails * corrected mismatch between example and default config (server.db/server.database)
-rw-r--r--Changelog.md3
-rw-r--r--config/defaults.yml3
-rw-r--r--config/diaspora.yml.example6
-rw-r--r--config/load_config.rb19
-rw-r--r--config/unicorn.rb5
-rwxr-xr-xscript/server2
6 files changed, 28 insertions, 10 deletions
diff --git a/Changelog.md b/Changelog.md
index 5b33cde11..7dd43e3bf 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -6,6 +6,8 @@
* Last post link isn't displayed anymore if there are no visible posts [#3750](https://github.com/diaspora/diaspora/issues/3750)
* Ported tag followings to backbone [#3713](https://github.com/diaspora/diaspora/pull/3713)
* Extracted configuration system to a gem.
+* Made number of unicorn workers configurable.
+* Made loading of the configuration environment independent of Rails.
## Bug Fixes
@@ -13,6 +15,7 @@
* Validate input on sending invitations, validate email format, send correct ones. [#3748](https://github.com/diaspora/diaspora/pull/3748), [#3271](https://github.com/diaspora/diaspora/issues/3271)
* moved Aspects JS initializer to the correct place so aspect selection / deselection works again [#3737] (https://github.com/diaspora/diaspora/pull/3737)
* Do not strip "markdown" in links when posting to services [#3765](https://github.com/diaspora/diaspora/issues/3765)
+* Renamed `server.db` to `server.database` to match the example configuration.
# 0.0.2.0
diff --git a/config/defaults.yml b/config/defaults.yml
index 611f328cc..f75a930bf 100644
--- a/config/defaults.yml
+++ b/config/defaults.yml
@@ -28,7 +28,8 @@ defaults:
server:
port: 3000
rails_environment: 'development'
- db: 'mysql'
+ database: 'mysql'
+ unicorn_worker: 2
embed_resque_worker: false
resque_workers: 1
privacy:
diff --git a/config/diaspora.yml.example b/config/diaspora.yml.example
index c81a60e30..b44f9e22b 100644
--- a/config/diaspora.yml.example
+++ b/config/diaspora.yml.example
@@ -111,7 +111,11 @@ configuration: ## Section
## The database type the server should use by default.
## Valid choices are 'mysql' and 'postgres'
#database: 'mysql'
-
+
+ ## Number of unicorn worker processes, increase this if
+ ## you have many users
+ #unicorn_worker: 2
+
## Embed a resque worker inside the unicorn process, useful for
## minimal Heroku setups
#embed_resque_worker: true
diff --git a/config/load_config.rb b/config/load_config.rb
index 88f8d4c4d..9faff8cd9 100644
--- a/config/load_config.rb
+++ b/config/load_config.rb
@@ -1,6 +1,13 @@
-require Rails.root.join('lib', 'configuration_methods')
+require 'configurate'
-config_dir = Rails.root.join("config")
+rails_root = Pathname.new(__FILE__).dirname.join('..').expand_path
+rails_env = ENV['RACK_ENV']
+rails_env ||= ENV['RAILS_ENV']
+rails_env ||= 'development'
+
+require rails_root.join('lib', 'configuration_methods')
+
+config_dir = rails_root.join("config")
if File.exists?(config_dir.join("application.yml"))
$stderr.puts "ATTENTION: There's a new configuration system, please remove your"
@@ -12,7 +19,7 @@ AppConfig ||= Configurate::Settings.create do
add_provider Configurate::Provider::Dynamic
add_provider Configurate::Provider::Env
- unless heroku? || Rails.env == "test" || File.exists?(config_dir.join("diaspora.yml"))
+ unless heroku? || rails_env == "test" || File.exists?(config_dir.join("diaspora.yml"))
$stderr.puts "FATAL: Configuration not found. Copy over diaspora.yml.example"
$stderr.puts " to diaspora.yml and edit it to your needs."
Process.exit(1)
@@ -20,20 +27,20 @@ AppConfig ||= Configurate::Settings.create do
add_provider Configurate::Provider::YAML,
config_dir.join("diaspora.yml"),
- namespace: Rails.env, required: false
+ namespace: rails_env, required: false
add_provider Configurate::Provider::YAML,
config_dir.join("diaspora.yml"),
namespace: "configuration", required: false
add_provider Configurate::Provider::YAML,
config_dir.join("defaults.yml"),
- namespace: Rails.env
+ namespace: rails_env
add_provider Configurate::Provider::YAML,
config_dir.join("defaults.yml"),
namespace: "defaults"
extend Configuration::Methods
- if Rails.env == "production" && (environment.certificate_authorities.blank? || !File.file?(environment.certificate_authorities.get))
+ if rails_env == "production" && (environment.certificate_authorities.blank? || !File.file?(environment.certificate_authorities.get))
$stderr.puts "FATAL: Diaspora doesn't know where your certificate authorities are. Please ensure they are set to a valid path in diaspora.yml"
Process.exit(1)
end
diff --git a/config/unicorn.rb b/config/unicorn.rb
index 00d9b413c..456fecf95 100644
--- a/config/unicorn.rb
+++ b/config/unicorn.rb
@@ -1,10 +1,13 @@
rails_env = ENV['RAILS_ENV'] || 'development'
+require 'pathname'
+require Pathname.new(__FILE__).expand_path.dirname.join('load_config')
+
# Enable and set these to run the worker as a different user/group
#user = 'diaspora'
#group = 'diaspora'
-worker_processes 1
+worker_processes AppConfig.server.unicorn_worker.to_i
## Load the app before spawning workers
preload_app true
diff --git a/script/server b/script/server
index b4966cc23..fab954e93 100755
--- a/script/server
+++ b/script/server
@@ -34,7 +34,7 @@ fi
os=`uname -s`
eval $(bundle exec ruby ./script/get_config.rb \
port=server.port \
- db=server.db \
+ db=server.database \
workers=server.resque_workers \
single_process_mode=environment.single_process_mode?
embed_resque_worker=server.embed_resque_worker