Add a timeout to the change list pages
This commit is contained in:
parent
b3ce6fdeec
commit
cf682f49b3
7 changed files with 38 additions and 18 deletions
|
@ -216,6 +216,8 @@ class ApplicationController < ActionController::Base
|
|||
raise OSM::APIBadMethodError.new(method) unless ok
|
||||
end
|
||||
|
||||
##
|
||||
# wrap an api call in a timeout
|
||||
def api_call_timeout
|
||||
SystemTimer.timeout_after(APP_CONFIG['api_timeout']) do
|
||||
yield
|
||||
|
@ -224,6 +226,22 @@ class ApplicationController < ActionController::Base
|
|||
raise OSM::APITimeoutError
|
||||
end
|
||||
|
||||
##
|
||||
# wrap a web page in a timeout
|
||||
def web_timeout
|
||||
SystemTimer.timeout_after(APP_CONFIG['web_timeout']) do
|
||||
yield
|
||||
end
|
||||
rescue ActionView::TemplateError => ex
|
||||
if ex.original_exception.is_a?(Timeout::Error)
|
||||
render :action => "timeout"
|
||||
else
|
||||
raise
|
||||
end
|
||||
rescue Timeout::Error
|
||||
render :action => "timeout"
|
||||
end
|
||||
|
||||
##
|
||||
# extend caches_action to include the parameters, locale and logged in
|
||||
# status in all cache keys
|
||||
|
|
|
@ -4,7 +4,7 @@ class BrowseController < ApplicationController
|
|||
before_filter :authorize_web
|
||||
before_filter :set_locale
|
||||
before_filter { |c| c.check_database_readable(true) }
|
||||
around_filter :timeout, :except => [:start]
|
||||
around_filter :web_timeout, :except => [:start]
|
||||
|
||||
def start
|
||||
end
|
||||
|
@ -77,20 +77,4 @@ class BrowseController < ApplicationController
|
|||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def timeout
|
||||
SystemTimer.timeout_after(30) do
|
||||
yield
|
||||
end
|
||||
rescue ActionView::TemplateError => ex
|
||||
if ex.original_exception.is_a?(Timeout::Error)
|
||||
render :action => "timeout"
|
||||
else
|
||||
raise
|
||||
end
|
||||
rescue Timeout::Error
|
||||
render :action => "timeout"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,8 @@ class ChangesetController < ApplicationController
|
|||
before_filter :check_api_writable, :only => [:create, :update, :delete, :upload, :include]
|
||||
before_filter :check_api_readable, :except => [:create, :update, :delete, :upload, :download, :query]
|
||||
after_filter :compress_output
|
||||
around_filter :api_call_handle_error
|
||||
around_filter :api_call_handle_error, :except => [:list, :list_user, :list_bbox]
|
||||
around_filter :web_timeout, :only => [:list, :list_user, :list_bbox]
|
||||
|
||||
filter_parameter_logging "<osmChange version"
|
||||
|
||||
|
|
12
app/views/changeset/timeout.atom.builder
Normal file
12
app/views/changeset/timeout.atom.builder
Normal file
|
@ -0,0 +1,12 @@
|
|||
atom_feed(:language => I18n.locale, :schema_date => 2009,
|
||||
:id => url_for(params.merge({ :only_path => false })),
|
||||
:root_url => url_for(params.merge({ :only_path => false, :format => nil })),
|
||||
"xmlns:georss" => "http://www.georss.org/georss") do |feed|
|
||||
feed.title @title
|
||||
|
||||
feed.subtitle :type => 'xhtml' do |xhtml|
|
||||
xhtml.p do |p|
|
||||
p << t('changeset.timeout.sorry')
|
||||
end
|
||||
end
|
||||
end
|
1
app/views/changeset/timeout.html.erb
Normal file
1
app/views/changeset/timeout.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<p><%= t'changeset.timeout.sorry' %></p>
|
|
@ -13,6 +13,8 @@ standard_settings: &standard_settings
|
|||
geonames_zoom: 12
|
||||
# Timeout for API calls in seconds
|
||||
api_timeout: 300
|
||||
# Timeout for web pages in seconds
|
||||
web_timeout: 30
|
||||
# Periods (in hours) which are allowed for user blocks
|
||||
user_block_periods: [0, 1, 3, 6, 12, 24, 48, 96]
|
||||
# Rate limit for message sending
|
||||
|
|
|
@ -297,6 +297,8 @@ en:
|
|||
description_user: "Changesets by {{user}}"
|
||||
description_bbox: "Changesets within {{bbox}}"
|
||||
description_user_bbox: "Changesets by {{user}} within {{bbox}}"
|
||||
timeout:
|
||||
sorry: "Sorry, the list of changesets you requested took too long to retrieve."
|
||||
diary_entry:
|
||||
new:
|
||||
title: New Diary Entry
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue