Skip to content
Browse files

* made number of unicorn worker processes configurable

* made configuration loader indepenent of rails
* corrected mismatch between example and default config (server.db/server.database)
  • Loading branch information...
1 parent 669dd87 commit 2a7a0b7b990b70835e336ddffe62bf0e4b198ac4 @jhass jhass committed Nov 30, 2012
Showing with 28 additions and 10 deletions.
  1. +3 −0 Changelog.md
  2. +2 −1 config/defaults.yml
  3. +5 −1 config/diaspora.yml.example
  4. +13 −6 config/load_config.rb
  5. +4 −1 config/unicorn.rb
  6. +1 −1 script/server
View
3 Changelog.md
@@ -6,13 +6,16 @@
* 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
* Force Typhoeus/cURL to use the CA bundle we query via the config. Also add a setting for extra verbose output.
* 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
View
3 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:
View
6 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
View
19 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,28 +19,28 @@
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)
end
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
View
5 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
View
2 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

0 comments on commit 2a7a0b7

Please sign in to comment.
Something went wrong with that request. Please try again.