示例#1
0
    def handle(self, *test_labels, **options):
        
        nochange = options.get('nochange',False)
        
        # Create a random SECRET_KEY hash, and put it in the main settings.
        main_secrets_file = join(structure.CONF_DIR, 'secrets.py')

        if not exists(main_secrets_file):
            if nochange:
                print 'secrets.py file missing'
            else:
                secrets_contents = make_secrets()
                with open(main_secrets_file, 'w') as secrets:
                    secrets.writelines(secrets_contents)

        servers_contents = nginx_enabled(cluster_name="live",release_project_dir=True)
        with open(join(structure.CONF_DIR,"live.nginx.conf"), 'w') as nginx_conf:
            nginx_conf.writelines(servers_contents)
            
        servers_contents = nginx_enabled(cluster_name="staged",release_project_dir=False)
        with open(join(structure.CONF_DIR,"staged.nginx.conf"), 'w') as nginx_conf:
            nginx_conf.writelines(servers_contents)
            
        servers_contents = nginx_enabled(cluster_name="dev",release_project_dir=False)
        with open(join(structure.CONF_DIR,"dev.nginx.conf"), 'w') as nginx_conf:
            nginx_conf.writelines(servers_contents)
示例#2
0
    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)