#NEWLINE# def add_webserver_virtual_host( self ) : #NEWLINE# #INDENT# '\n            Uploads the virtual host template and restart nginx to update the config\n        ' #NEWLINE# context = { #NEWLINE# #INDENT# 'app' : self . app_name , #NEWLINE# 'gunicorn_port' : config . get ( 'gunicorn_port' , 8000 ) , #NEWLINE# 'server_port' : config . get ( 'server_port' , 80 ) , #NEWLINE# #UNINDENT# } #NEWLINE# server_name = config . get ( 'server_name' ) #NEWLINE# if server_name : #NEWLINE# #INDENT# context [ 'server_name' ] = 'server_name {0};' . format ( server_name ) #NEWLINE# #UNINDENT# upload_template ( 'templates/nginx_vhost.conf' , '/etc/nginx/sites-available/{0}.conf' . format ( context . app_name ) , context = context , overwrite = True ) #NEWLINE# with settings ( warn_only = True ) : #NEWLINE# #INDENT# run ( 'rm /etc/nginx/sites-enabled/default' ) #NEWLINE# run ( 'rm /etc/nginx/sites-enabled/{0}.conf' . format ( self . app_name ) ) #NEWLINE# #UNINDENT# run ( 'ln -s /etc/nginx/sites-available/{app}.conf /etc/nginx/sites-enabled/{app}.conf' . format ( app = self . app_name ) ) #NEWLINE# run ( 'service nginx restart' )