Dashboard warning when GC params are default

This commit is contained in:
Neil Lalonde 2013-03-20 16:16:23 -04:00
parent c8508d3f26
commit d28d81a590
4 changed files with 21 additions and 2 deletions

View File

@ -7,7 +7,7 @@
{{i18n admin.dashboard.problems_found}}
<ul>
{{#each problem in problems}}
<li>{{problem}}</li>
<li>{{{problem}}}</li>
{{/each}}
</ul>
</p>

View File

@ -10,7 +10,7 @@ class AdminDashboardData
@json ||= {
reports: REPORTS.map { |type| Report.find(type) },
total_users: User.count,
problems: [rails_env_check, host_names_check].compact
problems: [rails_env_check, host_names_check, gc_checks].compact
}.merge(
SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {}
)
@ -23,4 +23,8 @@ class AdminDashboardData
def host_names_check
I18n.t("dashboard.host_names_warning") if ['localhost', 'production.localhost'].include?(Discourse.current_hostname)
end
def gc_checks
I18n.t("dashboard.gc_warning") if ENV['RUBY_GC_MALLOC_LIMIT'].nil?
end
end

View File

@ -286,6 +286,7 @@ en:
dashboard:
rails_env_warning: "Your server is running in %{env} mode."
host_names_warning: "Your config/database.yml file is using the default localhost hostname. Update it to use your site's hostname."
gc_warning: 'Your server is using default ruby garbage collection parameters, which will not give you the best performance. Read this topic on performance tuning: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>.'
site_settings:
default_locale: "The default language of this Discourse instance (ISO 639-1 Code)"

View File

@ -40,4 +40,18 @@ describe AdminDashboardData do
end
end
describe 'gc_checks' do
subject { AdminDashboardData.new.gc_checks }
it 'returns nil when gc params are set' do
ENV.stubs(:[]).with('RUBY_GC_MALLOC_LIMIT').returns(90000000)
subject.should be_nil
end
it 'returns a string when gc params are not set' do
ENV.stubs(:[]).with('RUBY_GC_MALLOC_LIMIT').returns(nil)
subject.should_not be_nil
end
end
end