def add_themaestro(): from django.conf import settings #TODO patch thepian.conf.settings instead ? from thepian.conf import structure print 'Enabling maestro environment' if 'themaestro.app' not in settings.INSTALLED_APPS: settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + ['themaestro.app'] if 'themaestro.middleware.StandardExceptionMiddleware' in settings.MIDDLEWARE_CLASSES: settings.MIDDLEWARE_CLASSES = list(settings.MIDDLEWARE_CLASSES) + ['themaestro.middleware.StandardExceptionMiddleware'] if not hasattr(settings,'URLCONFS'): settings.URLCONFS = { 'www': settings.ROOT_URLCONF } if 'media' not in settings.URLCONFS: settings.URLCONFS['media'] = 'themaestro.media_urls' #TODO if more shards add for setting in settings.MACHINE_SETTINGS: if setting in structure.machine: setattr(settings,setting,structure.machine[setting]) if structure.CLUSTER: settings.DOMAINS = structure.CLUSTER.get('domains',settings.DOMAINS) settings.MEDIA_DOMAIN = structure.CLUSTER.get('media',"media.%s" % settings.DOMAINS[0]) settings.MEDIA_URL = 'http://' + settings.MEDIA_DOMAIN structure.ensure_target_dirs() import django.views.debug import themaestro.debug django.views.debug.technical_404_response = themaestro.debug.technical_404_response
def handle(self, *modulenames, **options): #TODO make sure memcached couchdb are started try: # is this needed? fs.symlink(structure.SCRIPT_PATH,'/usr/local/bin/maestro',replace=True) nginx_installed() #TODO create <project>/log dir for nginx structure.ensure_target_dirs() structure.machine.uploads_area.require_directory(structure.UPLOADS_DIR) structure.machine.downloads_area.require_directory(structure.DOWNLOADS_DIR) structure.machine.log_area.require_directory(structure.LOG_DIR) structure.machine.pid_area.require_directory(structure.PID_DIR) #sock_dir = "/var/tmp/django" #import fs,os,stat #fs.makedirs(sock_dir) #os.chmod(sock_dir,0777) if settings.DEVELOPING: #TODO link in User Sites directory from os.path import join,exists,expanduser fs.symlink(structure.PROJECT_DIR,join(expanduser("~/Sites"),structure.PROJECT_NAME)) hosts = updated_hosts(change_file=True) dev_name = join(structure.CONF_DIR,"dev.nginx.conf") if not exists(dev_name): servers_contents = nginx_enabled(cluster_name="dev",release_project_dir=False) with open(dev_name, 'w') as nginx_conf: nginx_conf.writelines(servers_contents) dev_name = join(structure.CONF_DIR,"staged.nginx.conf") if not exists(dev_name): servers_contents = nginx_enabled(cluster_name="staged",release_project_dir=False) with open(dev_name, 'w') as nginx_conf: nginx_conf.writelines(servers_contents) symlink_local_nginx() except Warning, e: print self.style.NOTICE(e.message)