Permalink
Browse files

refactor script/server and associated stuff

  • Loading branch information...
1 parent b6d7bf8 commit f0ef4a764ecdbb329fbc0228da1229388243fbc1 @jhass jhass committed Oct 14, 2012
Showing with 132 additions and 134 deletions.
  1. +0 −1 .gitignore
  2. +13 −1 Changelog.md
  3. +2 −6 Gemfile
  4. +0 −7 Gemfile.lock
  5. +1 −1 Procfile
  6. +6 −2 config/defaults.yml
  7. +17 −4 config/diaspora.yml.example
  8. +0 −15 config/script_server.yml.example
  9. +1 −1 config/unicorn.rb
  10. +20 −28 script/get_config.rb
  11. +72 −68 script/server
View
@@ -6,7 +6,6 @@ app/assets/images/custom/*
# Configuration files
config/diaspora.yml
config/heroku.yml
-config/script_server.yml
config/initializers/secret_token.rb
config/redis.conf
config/deploy_config.yml
View
@@ -2,9 +2,21 @@
## Refactor
+### script/server
+
+* Uses foreman now
+* Reduce startup time by reducing calls to `script/get_config.rb`
+* `config/script_server.yml` is removed and replaced by the `server` section in `config/diaspora.yml`
+ Have a look at the updated example!
+* Thin is dropped in favour of unicorn
+* Already set versions of `RAILS_ENV` and `DB` are now prefered over those set in `config/diaspora.yml`
+* **Heroku setups:** `ENVIRONMENT_UNICORN_EMBED_RESQUE_WORKER` got renamed to `SERVER_EMBED_RESQUE_WORKER`
+
+### Other
+
* MessagesController. [#3657](https://github.com/diaspora/diaspora/pull/3657)
-## Add Features
+## Features
* Add password_confirmation field to registration page. [#3647](https://github.com/diaspora/diaspora/pull/3647)
View
@@ -6,7 +6,8 @@ gem 'rails', '3.2.8'
gem 'foreman', '0.59'
-gem 'thin', '1.4.1', :require => false
+gem 'unicorn', '4.3.1', :require => false
+
gem 'rails_autolink', '1.0.9'
# cross-origin resource sharing
@@ -43,11 +44,6 @@ group :production do # we don't install these on travis to speed up test runs
end
-# configuration
-
-group :heroku do
- gem 'unicorn', '4.3.1', :require => false
-end
# database
View
@@ -108,7 +108,6 @@ GEM
capybara (>= 1.1.2)
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
- daemons (1.1.9)
database_cleaner (0.8.0)
debugger (1.2.0)
columnize (>= 0.3.1)
@@ -124,7 +123,6 @@ GEM
warden (~> 1.2.1)
diff-lcs (1.1.3)
erubis (2.7.0)
- eventmachine (0.12.10)
excon (0.16.2)
execjs (1.4.0)
multi_json (~> 1.0)
@@ -374,10 +372,6 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
subexec (0.2.2)
- thin (1.4.1)
- daemons (>= 1.0.9)
- eventmachine (>= 0.12.6)
- rack (>= 1.0.0)
thor (0.16.0)
tilt (1.3.3)
timecop (0.5.1)
@@ -481,7 +475,6 @@ DEPENDENCIES
sass-rails (= 3.2.5)
selenium-webdriver (= 2.25.0)
spork (= 1.0.0rc3)
- thin (= 1.4.1)
timecop (= 0.5.1)
twitter (= 2.0.2)
typhoeus (= 0.3.3)
View
@@ -1,2 +1,2 @@
web: bundle exec unicorn -c config/unicorn.rb -p $PORT
-worker: env QUEUE=* bundle exec rake resque:work
+worker: env QUEUE=* bundle exec rake resque:work
View
@@ -25,8 +25,12 @@ defaults:
upload: false
host:
pubsub_server: 'https://pubsubhubbub.appspot.com/'
- unicorn:
- embed_resque_worker: false
+ server:
+ port: 3000
+ rails_environment: 'development'
+ db: 'mysql'
+ embed_resque_worker: false
+ resque_workers: 1
privacy:
jquery_cdn: true
google_analytics_key:
@@ -100,10 +100,23 @@ configuration: ## Section
## You likely don't want to change this.
#pubsub_server: 'https://pubsubhubbub.appspot.com/'
- unicorn: ## Section
- ## Embed a resque worker inside the unicorn process, useful for
- ## minimal Heroku setups
- #embed_resque_worker: true
+ server: ## Section
+ ## The port on which the appserver should listen
+ #port: 3000
+
+ ## The environment in which the server should be started by default.
+ #rails_environment: 'production'
+
+ ## The database type the server should use by default.
+ ## Valid choices are 'mysql' and 'postgres'
+ #database: 'mysql'
+
+ ## Embed a resque worker inside the unicorn process, useful for
+ ## minimal Heroku setups
+ #embed_resque_worker: true
+
+ ## Number of resque workers to start
+ #resque_workers: 1
## Settings probably affecting the privacy of your users
privacy: ## Section
@@ -1,15 +0,0 @@
-script_server:
- # Choose database. Currently supported: mysql, postgres
- db: "mysql"
-
- # Enable thin as application server
- enable_thin: true
-
- # Port on which thin should listen
- thin_port: 3000
-
- # Customize thin's startup
- default_thin_args: "-p $THIN_PORT -e $RAILS_ENV"
-
- # Possibilities are development, production
- rails_env: "development"
View
@@ -32,7 +32,7 @@
Resque.redis.client.disconnect
end
- if AppConfig.environment.unicorn.embed_resque_worker?
+ if AppConfig.server.embed_resque_worker?
# Clean up Resque workers killed by previous deploys/restarts
Resque.workers.each { |w| w.unregister_worker }
@resque_pid ||= spawn('bundle exec rake resque:work QUEUES=*')
View
@@ -3,9 +3,19 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
+unless ARGV.length >= 1
+ $stderr.puts "Usage: ./script/get_config.rb var=option | option [...]"
+ Process.exit(1)
+end
+
require 'rubygems'
require 'pathname'
+require 'active_support/core_ext/class/attribute_accessors'
+require 'active_support/core_ext/object/blank'
+require 'active_support/core_ext/module/delegation'
+require 'active_support/core_ext/module/method_names'
+
class Rails
def self.root
@@root ||= Pathname.new(File.expand_path(File.join(File.dirname(__FILE__), "..")))
@@ -14,38 +24,20 @@ def self.root
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 Rails.root.join("config/load_config")
-if ARGV.length >= 1
- setting_name = ARGV[0]
- if Rails.env == 'script_server' # load from the special script_server_config.yml file
- require 'yaml'
- script_server_config_file = Rails.root.join('config', 'script_server.yml')
- begin
- print YAML.load_file(script_server_config_file)['script_server'][setting_name]
- rescue
- $stderr.puts "Setting '#{setting_name}' not found in file #{script_server_config_file}."
- $stderr.puts "Does that file exist? If not, copy it from #{File.basename(script_server_config_file)}.example in the same directory and run this script again."
- Process.exit(1)
- end
- else # load from the general diaspora settings file
- require 'active_support/core_ext/class/attribute_accessors'
- require 'active_support/core_ext/object/blank'
- require 'active_support/core_ext/module/delegation'
- require 'active_support/core_ext/module/method_names'
- require Rails.root.join("config/load_config")
-
- setting = AppConfig.send(setting_name)
- setting = setting.get if setting.is_a?(Configuration::Proxy)
- print setting
+ARGV.each do |arg|
+ var, setting_name = arg.split("=")
+ setting_name = var unless setting_name
+ setting = AppConfig.send(setting_name)
+ setting = setting.get if setting.is_a?(Configuration::Proxy)
+ if var != setting_name
+ puts "#{var}=#{setting}"
+ else
+ puts setting
end
-else
- $stderr.puts "Usage: ./script/get_config.rb option [section]"
- $stderr.puts ""
- $stderr.puts "section defaults to development"
- Process.exit(1)
end
Oops, something went wrong.

0 comments on commit f0ef4a7

Please sign in to comment.