def symlink_local_nginx(cluster_names=('staged','dev')): for cluster_name in cluster_names: cluster = structure.CLUSTERS[cluster_name] enabled_conf_path = join(features["nginx"].NGINX_SITES_ENABLED, cluster['domains'][0]+".conf") conf_path = join(structure.CONF_DIR,"%s.nginx.conf" % cluster_name) fs.symlink(conf_path,enabled_conf_path,replace=True) fastcgi_path = join(features["nginx"].NGINX_ETC_DIR,'fastcgi.conf') geo_path = join(features["nginx"].NGINX_ETC_DIR,'geo.conf') fs.symlink(join(structure.CONF_DIR,'nginx.fastcgi.conf'),fastcgi_path,replace=True) #TODO fs.symlink(join(structure.CONF_DIR,'nginx.geo.conf'),fastcgi_path,replace=True) log_area.require_directory(structure.LOG_DIR) features["nginx"].reload()
def update_local_nginx(conf_lines): """ Save lines to local nginx enabled configuration and restart nginx """ fs.make_path(features["nginx"].NGINX_SITES_ENABLED) enabled_conf_path = join(features["nginx"].NGINX_SITES_ENABLED, structure.PROJECT_NAME+".local.conf") try: with open(enabled_conf_path,"w") as conf_file: conf_file.writelines(servers) # TODO make globally readable # if uid and gid: # os.chown(path, uid, gid) log_area.require_directory(structure.LOG_DIR) features["nginx"].reload() return except: raise Warning("Use sudo to modify %s" % feature.ETC_FILE)