mirror of
https://github.com/certbot/certbot.git
synced 2026-05-28 04:34:11 -04:00
Due to issues with piping and Nginx on Arch.
(cherry picked from commit 5fa2080558)
This commit is contained in:
parent
f671398a08
commit
b7152e0ba4
1 changed files with 14 additions and 13 deletions
|
|
@ -5,6 +5,7 @@ import re
|
|||
import shutil
|
||||
import socket
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
import OpenSSL
|
||||
|
|
@ -829,22 +830,22 @@ 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()
|
||||
proc = subprocess.Popen([nginx_ctl, "-c", nginx_conf, "-s", "reload"])
|
||||
proc.communicate()
|
||||
|
||||
if proc.returncode != 0:
|
||||
# Maybe Nginx isn't running
|
||||
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:
|
||||
# Enter recovery routine...
|
||||
raise errors.MisconfigurationError(
|
||||
"nginx restart failed:\n%s\n%s" % (stdout, stderr))
|
||||
# Write to temporary files instead of piping because of communication issues on Arch
|
||||
# https://github.com/certbot/certbot/issues/4324
|
||||
with tempfile.TemporaryFile() as out:
|
||||
with tempfile.TemporaryFile() as err:
|
||||
nginx_proc = subprocess.Popen([nginx_ctl, "-c", nginx_conf],
|
||||
stdout=out, stderr=err)
|
||||
nginx_proc.communicate()
|
||||
if nginx_proc.returncode != 0:
|
||||
# Enter recovery routine...
|
||||
raise errors.MisconfigurationError(
|
||||
"nginx restart failed:\n%s\n%s" % (out.read(), err.read()))
|
||||
|
||||
except (OSError, ValueError):
|
||||
raise errors.MisconfigurationError("nginx restart failed")
|
||||
|
|
|
|||
Loading…
Reference in a new issue