This file is very similar to cms/startup.py.  Is there some way we could refactor so that we don't have to repeat ourselves?  For instance, can't the modulestore code be in modulestore.py, and then invoked from here?