mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 00:37:51 +00:00
feat(nginx): Allow logging settings as site/combined/none
This commit is contained in:
parent
391dcf1e12
commit
5370129283
@ -25,13 +25,16 @@ def setup_sudoers(user):
|
||||
|
||||
|
||||
@click.command("nginx", help="Generate configuration files for NGINX")
|
||||
@click.option(
|
||||
"--logging", default="combined", type=click.Choice(["none", "site", "combined"])
|
||||
)
|
||||
@click.option(
|
||||
"--yes", help="Yes to regeneration of nginx config file", default=False, is_flag=True
|
||||
)
|
||||
def setup_nginx(yes=False):
|
||||
def setup_nginx(yes=False, logging="combined"):
|
||||
from bench.config.nginx import make_nginx_conf
|
||||
|
||||
make_nginx_conf(bench_path=".", yes=yes)
|
||||
make_nginx_conf(bench_path=".", yes=yes, logging=logging)
|
||||
|
||||
|
||||
@click.command("reload-nginx", help="Checks NGINX config file and reloads service")
|
||||
|
@ -13,7 +13,7 @@ from bench.bench import Bench
|
||||
from bench.utils import get_bench_name
|
||||
|
||||
|
||||
def make_nginx_conf(bench_path, yes=False):
|
||||
def make_nginx_conf(bench_path, yes=False, logging=None):
|
||||
conf_path = os.path.join(bench_path, "config", "nginx.conf")
|
||||
|
||||
if not yes and os.path.exists(conf_path):
|
||||
@ -43,6 +43,7 @@ def make_nginx_conf(bench_path, yes=False):
|
||||
"allow_rate_limiting": allow_rate_limiting,
|
||||
# for nginx map variable
|
||||
"random_string": "".join(random.choice(string.ascii_lowercase) for i in range(7)),
|
||||
"logging": logging,
|
||||
}
|
||||
|
||||
if allow_rate_limiting:
|
||||
|
@ -114,11 +114,18 @@ server {
|
||||
|
||||
{% endfor -%}
|
||||
|
||||
# logs in var
|
||||
{%- if logging == "site" -%}
|
||||
|
||||
access_log /var/log/nginx/{{ site_name }}_access.log main;
|
||||
error_log /var/log/nginx/{{ site_name }}_error.log;
|
||||
|
||||
|
||||
{%- elif logging == "combined" -%}
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
{%- endif %}
|
||||
|
||||
# optimizations
|
||||
sendfile on;
|
||||
keepalive_timeout 15;
|
||||
|
Loading…
Reference in New Issue
Block a user