Permalink
Browse files

Switch to thread model

  • Loading branch information...
1 parent cddca09 commit 9214480e87416371f257a0a15e44f4e313a40f8c @kyledrake kyledrake committed Jul 27, 2012
Showing with 2 additions and 58 deletions.
  1. +0 −3 Gemfile
  2. +2 −5 environment.rb
  3. +0 −50 rainbows_config.rb
View
@@ -1,6 +1,5 @@
source :rubyforge
gem 'sinatra', '1.2.6', :require => 'sinatra/base'
-gem 'sinatra-synchrony', '0.2.1', :require => 'sinatra/synchrony'
gem 'json', '1.5.3'
gem 'dm-core', '1.2.0'
gem 'dm-timestamps', '1.2.0'
@@ -10,10 +9,8 @@ gem 'rack-cache', '1.0.1', :require => 'rack/cache'
gem 'rake', '0.8.7', :require => nil
gem 'geoloqi', '0.9.27'
gem 'hashie', '1.0.0'
-gem 'rainbows', '4.3.1'
gem 'rack-mobile-detect', '0.3.0', :require => 'rack/mobile-detect'
gem 'aws-ses', :require => 'aws/ses'
-gem 'thin'
group :development do
gem 'pry'
View
@@ -76,7 +76,6 @@ def onclick_form(meth)
configure do
use Rack::MobileDetect
- register Sinatra::Synchrony
if test?
set :sessions, false
else
@@ -98,11 +97,9 @@ def onclick_form(meth)
APPLICATION_ACCESS_TOKEN = config_hash['oauth_token']
AWS_KEY = config_hash['aws_key']
AWS_SECRET = config_hash['aws_secret']
- Faraday.default_adapter = :em_synchrony
Geoloqi.config :client_id => config_hash['client_id'],
:client_secret => config_hash['client_secret'],
- :use_hashie_mash => true,
- :adapter => :em_synchrony
+ :use_hashie_mash => true
DataMapper.finalize
DataMapper.setup :default, ENV['DATABASE_URL'] || config_hash['database']
# DataMapper.auto_upgrade!
@@ -128,4 +125,4 @@ def url_without_path
class Array; def sum; inject( nil ) { |sum,x| sum ? sum+x : x }; end; end
-require File.join(Controller.root, 'controller.rb')
+require File.join(Controller.root, 'controller.rb')
View
@@ -1,50 +0,0 @@
-Rainbows! do
- name = 'mapattack'
- use :EventMachine
- client_max_body_size nil # This is set in nginx
- # keepalive_timeout 1
-
- case ENV['RACK_ENV'].to_sym
- when :development
- # This has weird issues with kqueue on OSX, use thin.
- listen 9292
- when :production
- worker_processes 4
- worker_connections 1024
- timeout 30
- listen "unix:/var/run/geoloqi/#{name}.sock", :backlog => 4096
- pid "/var/run/geoloqi/#{name}.pid"
- stderr_path "/var/log/geoloqi/#{name}.log"
- stdout_path "/var/log/geoloqi/#{name}.log"
-
- ###
- # Hardcore performance tweaks, described here: https://github.com/blog/517-unicorn
- ###
-
- # This loads the app in master, and then forks workers. Kill with USR2 and it will do a graceful restart using the block proceeding.
- preload_app true
-
- before_fork do |server, worker|
- ##
- # When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
- # immediately start loading up a new version of itself (loaded with a new
- # version of our app). When this new Unicorn is completely loaded
- # it will begin spawning workers. The first worker spawned will check to
- # see if an .oldbin pidfile exists. If so, this means we've just booted up
- # a new Unicorn and need to tell the old one that it can now die. To do so
- # we send it a QUIT.
- #
- # Using this method we get 0 downtime deploys.
-
- old_pid = "/var/run/geoloqi/#{name}.pid.oldbin"
- if File.exists?(old_pid) && server.pid != old_pid
- begin
- Process.kill("QUIT", File.read(old_pid).to_i)
- rescue Errno::ENOENT, Errno::ESRCH
- # someone else did our job for us
- end
- end
- end
-
- end
-end

0 comments on commit 9214480

Please sign in to comment.