2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-23 04:29:02 +00:00

replace default nginx config in case of centos7

This commit is contained in:
Pratik Vyas 2014-11-11 09:42:17 +05:30
parent 3cfdf6972c
commit 0608f04d7e
2 changed files with 55 additions and 1 deletions

View File

@ -1,6 +1,8 @@
from .utils import get_program, exec_cmd, get_cmd_output
from .config import generate_nginx_config, generate_supervisor_config
from jinja2 import Environment, PackageLoader
import os
import shutil
def restart_service(service):
program = get_program(['systemctl', 'service'])
@ -24,12 +26,20 @@ def remove_default_nginx_configs():
if os.path.exists(conf_file):
os.unlink(conf_file)
def is_centos7():
return os.path.exists('/etc/redhat-release') and get_cmd_output("cat /etc/redhat-release | sed 's/Linux\ //g' | cut -d' ' -f3 | cut -d. -f1").strip() == '7'
def copy_default_nginx_config():
shutil.copy(os.path.join(os.path.dirname(__file__), 'templates', 'nginx_default.conf'), '/etc/nginx/nginx.conf')
def setup_production(bench='.'):
generate_supervisor_config(bench=bench)
generate_nginx_config(bench=bench)
remove_default_nginx_configs()
if os.path.exists('/etc/redhat-release') and get_cmd_output("cat /etc/redhat-release | sed 's/Linux\ //g' | cut -d' ' -f3 | cut -d. -f1").strip() == '7':
if is_centos7():
supervisor_conf_filename = 'frappe.ini'
else:
supervisor_conf_filename = 'frappe.conf'

View File

@ -0,0 +1,44 @@
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
index index.html index.htm;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}