* made number of unicorn worker processes configurable

* made configuration loader indepenent of rails
* corrected mismatch between example and default config (server.db/server.database)
This commit is contained in:
Jonne Haß 2012-11-30 14:00:25 +01:00
parent 669dd87b11
commit 2a7a0b7b99
6 changed files with 28 additions and 10 deletions

View file

@ -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

View file

@ -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 file

@ -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 file

@ -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

View file

@ -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 file

@ -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