2

I'm doing some refactoring of my entities and I'd like to temporarily shut down all access to my app engine app (except for admin) to prevent users modifying any entities while I am performing the maintenance.

What is a straightforward way to do this? The only easy way I can think of is to create a new app.yaml file where admin is required for all pages. One downside to this is that I wouldn't be able to give users a friendly message that access will be restored soon.

Any better ways of doing this?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
new name
  • 15,861
  • 19
  • 68
  • 114

2 Answers2

3

Use the Admin Console's Application Settings tab "Disable Datastore Writes": https://developers.google.com/appengine/docs/adminconsole/applicationsettings#Disable_Datastore_Writes

This sets your datastore to read-only mode and prevents any users from making changes.

EDIT: Here's a good write-up on how to modify your app to gracefully degrade during downtime: https://developers.google.com/appengine/docs/python/howto/maintenance

Sologoub
  • 5,312
  • 6
  • 37
  • 65
  • Thanks for the info. The only problem is that I want to be able to do datastore writes as administrator and it looks like your solution won't allow me to do that. – new name Dec 28 '12 at 15:01
  • Just tried this: the writes are disabled for the app, but you can still perform operations in the Admin Datastore Viewer. I have not tried the bulkloader. – Sologoub Dec 28 '12 at 16:59
  • Please see my answer and let me know what you think. – new name Jan 27 '13 at 15:55
0

I've created a maintenance mode by modifying the WSGIApplication.

My main.py now looks like this:

import webapp2
import views

maintenance_mode = False

# These routes need to be always available
routes = [
    # Static pages
    (r'/(|about|contact|help|faq|terms|privacy|users|methods)', 
     views.Static),
    # Other routes that should always be available here
]

if maintenance_mode:
    routes += [(r'/.*', views.Maintenance)] # Displays a maintenance message
    application = webapp2.WSGIApplication(routes)

else:
    routes += [
        # Routes that are not available in maintenance mode
    ]
    application = webapp2.WSGIApplication(routes)

views.py has the following:

class Maintenance(webapp2.RequestHandler):
    def get(self):
        self.response.write (
            "My app is down for maintenance and should be back up shortly.")
    def post(self):
        self.response.write (
            "My app is down for maintenance and should be back up shortly.")

This seems like an easy and safe solution, but please let me know if you seen any flaws in this approach.

new name
  • 15,861
  • 19
  • 68
  • 114