def nginx_restart(nginx_ctl, nginx_conf='/etc/nginx.conf'):
 try:
  proc = subprocess.Popen([nginx_ctl, '-c', nginx_conf, '-s', 'reload'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  (stdout, stderr) = proc.communicate()
  if (proc.returncode != 0):
   nginx_proc = subprocess.Popen([nginx_ctl, '-c', nginx_conf], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
   (stdout, stderr) = nginx_proc.communicate()
   if (nginx_proc.returncode != 0):
    raise errors.MisconfigurationError(('nginx restart failed:\n%s\n%s' % (stdout, stderr)))
 except (OSError, ValueError):
  raise errors.MisconfigurationError('nginx restart failed')
 time.sleep(1)

def nginx_restart ( nginx_ctl , nginx_conf = '/etc/nginx.conf' ) : try : proc = subprocess . Popen ( [ nginx_ctl , '-c' , nginx_conf , '-s' , 'reload' ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) ( stdout , stderr ) = proc . communicate ( ) if ( proc . returncode != 0 ) : nginx_proc = subprocess . Popen ( [ nginx_ctl , '-c' , nginx_conf ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) ( stdout , stderr ) = nginx_proc . communicate ( ) if ( nginx_proc . returncode != 0 ) : raise errors . MisconfigurationError ( ( 'nginx restart failed:\n%s\n%s' % ( stdout , stderr ) ) ) except ( OSError , ValueError ) : raise errors . MisconfigurationError ( 'nginx restart failed' ) time . sleep ( 1 )
restarts the nginx server .