INNER CODE UNIT · Python
nginx_command
kejilion/sh · site_access_config.py:62
def nginx_command(*arguments):
"""Only fixed commands on the script's existing nginx container."""
try:
subprocess.run(['/usr/bin/docker', 'exec', 'nginx', 'nginx', *arguments],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
env={'PATH': '/usr/bin:/bin', 'LC_ALL': 'C'},
timeout=30, check=True)
except (OSError, subprocess.SubprocessError) as exc:
raise ConfigError('Nginx validation or reload failed') from exc
def apply_config(directory: str, name: str, expected_sha256: str, server_index: int,
scope: str, location: str, modifier: str, action: str,
*, realm: str = '', user_file: str = '') -> str:
return edit_config(directory, name, expected_sha256, server_index, scope, location, modifier,
action, realm=realm, user_file=user_file,
validate=lambda: nginx_command('-t'),
reload_config=lambda: nginx_command('-s', 'reload'))