Allow the API to be taken offline completely as well as being put into
readonly mode,
This commit is contained in:
parent
27d8f2ef63
commit
9c01c4cb63
11 changed files with 25 additions and 9 deletions
|
@ -2,7 +2,7 @@ class AmfController < ApplicationController
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
|
|
||||||
session :off
|
session :off
|
||||||
before_filter :check_availability
|
before_filter :check_write_availability
|
||||||
|
|
||||||
# to log:
|
# to log:
|
||||||
# RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
|
# RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class ApiController < ApplicationController
|
class ApiController < ApplicationController
|
||||||
|
|
||||||
session :off
|
session :off
|
||||||
|
before_filter :check_read_availability, :except => [:capabilities]
|
||||||
after_filter :compress_output
|
after_filter :compress_output
|
||||||
|
|
||||||
#COUNT is the number of map requests to allow before exiting and starting a new process
|
#COUNT is the number of map requests to allow before exiting and starting a new process
|
||||||
|
|
|
@ -39,8 +39,16 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_availability
|
def check_read_availability
|
||||||
if API_READONLY
|
if API_STATUS == :offline
|
||||||
|
response.headers['Error'] = "Database offline for maintenance"
|
||||||
|
render :nothing => true, :status => :service_unavailable
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_write_availability
|
||||||
|
if API_STATUS == :offline or API_STATUS == :readonly
|
||||||
response.headers['Error'] = "Database offline for maintenance"
|
response.headers['Error'] = "Database offline for maintenance"
|
||||||
render :nothing => true, :status => :service_unavailable
|
render :nothing => true, :status => :service_unavailable
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -3,7 +3,8 @@ class NodeController < ApplicationController
|
||||||
|
|
||||||
session :off
|
session :off
|
||||||
before_filter :authorize, :only => [:create, :update, :delete]
|
before_filter :authorize, :only => [:create, :update, :delete]
|
||||||
before_filter :check_availability, :only => [:create, :update, :delete]
|
before_filter :check_write_availability, :only => [:create, :update, :delete]
|
||||||
|
before_filter :check_read_availability, :except => [:create, :update, :delete]
|
||||||
after_filter :compress_output
|
after_filter :compress_output
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
|
@ -2,6 +2,7 @@ class OldNodeController < ApplicationController
|
||||||
require 'xml/libxml'
|
require 'xml/libxml'
|
||||||
|
|
||||||
session :off
|
session :off
|
||||||
|
before_filter :check_read_availability
|
||||||
after_filter :compress_output
|
after_filter :compress_output
|
||||||
|
|
||||||
def history
|
def history
|
||||||
|
|
|
@ -2,6 +2,7 @@ class OldSegmentController < ApplicationController
|
||||||
require 'xml/libxml'
|
require 'xml/libxml'
|
||||||
|
|
||||||
session :off
|
session :off
|
||||||
|
before_filter :check_read_availability
|
||||||
after_filter :compress_output
|
after_filter :compress_output
|
||||||
|
|
||||||
def history
|
def history
|
||||||
|
|
|
@ -2,6 +2,7 @@ class OldWayController < ApplicationController
|
||||||
require 'xml/libxml'
|
require 'xml/libxml'
|
||||||
|
|
||||||
session :off
|
session :off
|
||||||
|
before_filter :check_read_availability
|
||||||
after_filter :compress_output
|
after_filter :compress_output
|
||||||
|
|
||||||
def history
|
def history
|
||||||
|
|
|
@ -3,7 +3,8 @@ class SegmentController < ApplicationController
|
||||||
|
|
||||||
session :off
|
session :off
|
||||||
before_filter :authorize, :only => [:create, :update, :delete]
|
before_filter :authorize, :only => [:create, :update, :delete]
|
||||||
before_filter :check_availability, :only => [:create, :update, :delete]
|
before_filter :check_write_availability, :only => [:create, :update, :delete]
|
||||||
|
before_filter :check_read_availability, :except => [:create, :update, :delete]
|
||||||
after_filter :compress_output
|
after_filter :compress_output
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class SwfController < ApplicationController
|
class SwfController < ApplicationController
|
||||||
session :off
|
session :off
|
||||||
before_filter :check_availability
|
before_filter :check_read_availability
|
||||||
|
|
||||||
# to log:
|
# to log:
|
||||||
# RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
|
# RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
|
||||||
|
|
|
@ -3,7 +3,8 @@ class WayController < ApplicationController
|
||||||
|
|
||||||
session :off
|
session :off
|
||||||
before_filter :authorize, :only => [:create, :update, :delete]
|
before_filter :authorize, :only => [:create, :update, :delete]
|
||||||
before_filter :check_availability, :only => [:create, :update, :delete]
|
before_filter :check_write_availability, :only => [:create, :update, :delete]
|
||||||
|
before_filter :check_read_availability, :except => [:create, :update, :delete]
|
||||||
after_filter :compress_output
|
after_filter :compress_output
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
|
@ -77,8 +77,9 @@ end
|
||||||
# inflect.uncountable %w( fish sheep )
|
# inflect.uncountable %w( fish sheep )
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# Set to true to put the API in read-only mode
|
# Set to :readonly to put the API in read-only mode or :offline to
|
||||||
API_READONLY = false
|
# take it completely offline
|
||||||
|
API_STATUS = :online
|
||||||
|
|
||||||
# Include your application configuration below
|
# Include your application configuration below
|
||||||
SERVER_URL = ENV['OSM_SERVER_URL'] || 'www.openstreetmap.org'
|
SERVER_URL = ENV['OSM_SERVER_URL'] || 'www.openstreetmap.org'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue