added profile environment for perftools profiling (1.9.3 only)

This commit is contained in:
Sam 2013-03-10 17:21:56 -07:00
parent 45c4382cce
commit 22a4580df5
8 changed files with 73 additions and 2 deletions

View File

@ -108,3 +108,8 @@ end
# If you want to amend mini profiler to do the monkey patches in the railstie
# we are open to it.
gem 'rack-mini-profiler', git: 'git://github.com/SamSaffron/MiniProfiler'
# perftools only works on 1.9 atm
group :profile do
gem 'rack-perftools_profiler', require: 'rack/perftools_profiler', platform: :mri_19
end

View File

@ -307,9 +307,11 @@ GEM
omniauth-twitter (0.0.14)
multi_json (~> 1.3)
omniauth-oauth (~> 1.0)
open4 (1.3.0)
openid-redis-store (0.0.2)
redis
ruby-openid
perftools.rb (2.0.0)
pg (0.14.1)
polyglot (0.3.3)
progress (2.4.0)
@ -325,6 +327,10 @@ GEM
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-perftools_profiler (0.6.0)
open4 (~> 1.0)
perftools.rb (~> 2.0.0)
rack (~> 1.0)
rack-protection (1.3.2)
rack
rack-ssl (1.3.3)
@ -514,6 +520,7 @@ DEPENDENCIES
pg
pry-rails
rack-mini-profiler!
rack-perftools_profiler
rails
rails_multisite!
rake

View File

@ -123,6 +123,7 @@ class Topic < ActiveRecord::Base
return title unless SiteSetting.title_fancy_entities?
# We don't always have to require this, if fancy is disabled
# see: http://meta.discourse.org/t/pattern-for-defer-loading-gems-and-profiling-with-perftools-rb/4629
require 'redcarpet' unless defined? Redcarpet
Redcarpet::Render::SmartyPants.render(title)

View File

@ -7,7 +7,7 @@ require './lib/discourse_plugin_registry'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
Bundler.require(*Rails.groups(:assets => %w(development test profile)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end

View File

@ -30,3 +30,13 @@ production:
timeout: 5000
host_names:
- production.localhost # Update this to be the domain of your production site
profile:
adapter: postgresql
database: discourse_development
min_messages: warning
host: localhost
pool: 5
timeout: 5000
host_names:
- "localhost"

View File

@ -0,0 +1,45 @@
Discourse::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# in profile mode we serve static assets
config.serve_static_assets = true
# Compress JavaScripts and CSS
config.assets.compress = true
# stuff should be pre-compiled, allow compilation to make life easier
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true
# Specifies the header that your server uses for sending files
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {arguments: '-i'}
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
# I dunno ... perhaps the built-in minifier is using closure
# regardless it is blowing up
config.ember.variant = :development
config.ember.ember_location = "#{Rails.root}/app/assets/javascripts/external_production/ember.js"
config.ember.handlebars_location = "#{Rails.root}/app/assets/javascripts/external/handlebars-1.0.rc.3.js"
config.handlebars.precompile = true
config.middleware.use ::Rack::PerftoolsProfiler, :default_printer => 'gif'
end

View File

@ -10,7 +10,7 @@
# Discourse::Application.config.secret_token = "SET_SECRET_HERE"
# delete all lines below in production
if Rails.env.test? || Rails.env.development?
if Rails.env.test? || Rails.env.development? || Rails.env == "profile"
Discourse::Application.config.secret_token = "47f5390004bf6d25bb97083fb98e7cc133ab450ba814dd19638a78282b4ca291"
else
raise "You must set a secret token in ENV['SECRET_TOKEN'] or in config/initializers/secret_token.rb" if ENV['SECRET_TOKEN'].blank?

View File

@ -7,6 +7,9 @@ defaults: &defaults
development:
<<: *defaults
profile:
<<: *defaults
test:
<<: *defaults
db: 1