def handle_host(self,*args, **options): if not hasattr(state.env,'sites_created'): local_settings_dir = os.path.join(os.getcwd(),state.env.project_name,'sitesettings') sites = _get_django_sites() site_ids = sites.keys() site_ids.sort() for id in site_ids: sitesetting_path = os.path.join(state.env.project_name,'sitesettings',''.join([sites[id].replace('.','_'),'.py'])) if not os.path.exists(sitesetting_path): f = open(sitesetting_path, "w+") f.write("from %s.sitesettings.settings import *"% state.env.project_name) f.write("\nSITE_ID=%s\n"% str(id)) f.close() state.env.sites_created = True created = deploy_sitesettings() with settings(patch=True): deploy_wsgi() deploy_webconf() #activate sites activate_sites = [''.join([d.replace('.','_'),'-',state.env.project_version,'.conf']) for d in domain_sites()] site_paths = ['/etc/apache2','/etc/nginx'] #activate new sites for path in site_paths: for site in activate_sites: if not exists('/'.join([path,'sites-enabled',site])): sudo("chmod 644 %s" % '/'.join([path,'sites-available',site])) sudo("ln -s %s/sites-available/%s %s/sites-enabled/%s"% (path,site,path,site)) if state.env.verbosity: print " * enabled", "%s/sites-enabled/%s"% (path,site) reload_webservers()
def handle_host(self, *args, **kwargs): with settings(patch=True): deploy_wsgi() deploy_webconf() activate_sites = [''.join([ d.name.replace('.', '_'), '-', state.env.project_version, '.conf', ]) for d in domain_sites()] site_paths = ['/etc/apache2', '/etc/nginx'] # Activate new sites. for path in site_paths: for site in activate_sites: if not exists('/'.join([path, 'sites-enabled', site])): sudo("chmod 644 %s" % '/'.join( [path, 'sites-available', site])) sudo("ln -s %s/sites-available/%s %s/sites-enabled/%s" % ( path, site, path, site)) if state.env.verbosity: print " * enabled", "%s/sites-enabled/%s" % ( path, site) reload_webservers()
def handle_host(self,*args, **options): with settings(patch=True): deploy_wsgi() deploy_webconf() activate_sites = [''.join([d.name.replace('.','_'),'-',state.env.project_version,'.conf']) for d in domain_sites()] site_paths = ['/etc/apache2','/etc/nginx'] #activate new sites for path in site_paths: for site in activate_sites: if not exists('/'.join([path,'sites-enabled',site])): sudo("chmod 644 %s" % '/'.join([path,'sites-available',site])) sudo("ln -s %s/sites-available/%s %s/sites-enabled/%s"% (path,site,path,site)) if state.env.verbosity: print " * enabled", "%s/sites-enabled/%s"% (path,site) reload_webservers()