Improve Nginx service management
This commit is contained in:
@@ -18,6 +18,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
- Increase Nginx & MariaDB systemd open_files limits
|
||||
- Cronjob to update Cloudflare IPs list
|
||||
- mariadb-backup to perform full and non-blocking databases backup
|
||||
- Nginx configuration check before performing reload/restart
|
||||
- Nginx mapping to proxy web-socket connections
|
||||
|
||||
#### Changed
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ class WOSiteController(CementBaseController):
|
||||
Log.error(self, 'could not input site name')
|
||||
pargs.site_name = pargs.site_name.strip()
|
||||
(wo_domain, wo_www_domain) = ValidateDomain(pargs.site_name)
|
||||
wo_domain_type = GetDomainlevel(wo_domain)
|
||||
wo_domain_type, wo_root_domain = GetDomainlevel(wo_domain)
|
||||
wo_db_name = ''
|
||||
wo_db_user = ''
|
||||
wo_db_pass = ''
|
||||
@@ -424,7 +424,7 @@ class WOSiteCreateController(CementBaseController):
|
||||
|
||||
pargs.site_name = pargs.site_name.strip()
|
||||
(wo_domain, wo_www_domain) = ValidateDomain(pargs.site_name)
|
||||
wo_domain_type = GetDomainlevel(wo_domain)
|
||||
wo_domain_type, wo_root_domain = GetDomainlevel(wo_domain)
|
||||
if not wo_domain.strip():
|
||||
Log.error("Invalid domain name, "
|
||||
"Provide valid domain name")
|
||||
@@ -958,7 +958,7 @@ class WOSiteUpdateController(CementBaseController):
|
||||
(wo_domain,
|
||||
wo_www_domain, ) = ValidateDomain(pargs.site_name)
|
||||
wo_site_webroot = WOVariables.wo_webroot + wo_domain
|
||||
wo_domain_type = GetDomainlevel(wo_domain)
|
||||
wo_domain_type, wo_root_domain = GetDomainlevel(wo_domain)
|
||||
check_site = getSiteInfo(self, wo_domain)
|
||||
|
||||
if check_site is None:
|
||||
@@ -1820,7 +1820,7 @@ class WOSiteDeleteController(CementBaseController):
|
||||
|
||||
pargs.site_name = pargs.site_name.strip()
|
||||
(wo_domain, wo_www_domain) = ValidateDomain(pargs.site_name)
|
||||
wo_domain_type = GetDomainlevel(wo_domain)
|
||||
wo_domain_type, wo_root_domain = GetDomainlevel(wo_domain)
|
||||
wo_db_name = ''
|
||||
wo_prompt = ''
|
||||
wo_nginx_prompt = ''
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# NGINX CONFIGURATION FOR FASTCGI_CACHE EXCEPTION - WO v3.9.7
|
||||
# NGINX CONFIGURATION FOR FASTCGI_CACHE EXCEPTION - WO v3.9.8
|
||||
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
|
||||
|
||||
# do not cache xhtml request
|
||||
@@ -53,7 +53,7 @@ map $request_uri $uri_no_cache {
|
||||
"~*/commande/" 1;
|
||||
"~*/resetpass/" 1;
|
||||
}
|
||||
|
||||
# mobile_prefix needed for WP-Rocket
|
||||
map $http_user_agent $mobile_prefix {
|
||||
default "";
|
||||
"~*iphone" -mobile;
|
||||
@@ -78,7 +78,14 @@ map $skip_cache $cache_uri {
|
||||
default 'null cache';
|
||||
}
|
||||
|
||||
# http_prefix needed for WP-Rocket
|
||||
map $https $https_prefix {
|
||||
default "";
|
||||
on "-https";
|
||||
}
|
||||
|
||||
# needed to proxy web-socket connections
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
@@ -40,12 +40,14 @@ def GetDomainlevel(domain):
|
||||
for domain_suffix in Suffix_file:
|
||||
if (str(domain_suffix).strip()) == ('.'.join(domain_name[1:])):
|
||||
domain_type = 'domain'
|
||||
root_domain = domain_name[0:]
|
||||
break
|
||||
elif (str(domain_suffix).strip()) == ('.'.join(domain_name[2:])):
|
||||
domain_type = 'subdomain'
|
||||
root_domain = domain_name[1:]
|
||||
break
|
||||
else:
|
||||
domain_type = 'other'
|
||||
Suffix_file.close()
|
||||
|
||||
return (domain_type)
|
||||
return (domain_type, root_domain)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"""WordOps Service Manager"""
|
||||
import os
|
||||
import subprocess
|
||||
from wo.core.logging import Log
|
||||
|
||||
@@ -23,10 +22,14 @@ class WOService():
|
||||
if 'emerg' not in str(error_output):
|
||||
service_cmd = ('service {0} start'.format(service_name))
|
||||
retcode = subprocess.getstatusoutput(service_cmd)
|
||||
Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]")
|
||||
return True
|
||||
if retcode[0] == 0:
|
||||
Log.info(self, "Starting Nginx" +
|
||||
"[" + Log.ENDC + "OK" + Log.OKBLUE + "]")
|
||||
return True
|
||||
else:
|
||||
Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]")
|
||||
Log.info(
|
||||
self, "Starting Nginx" + "[" + Log.FAIL +
|
||||
"Failed" + Log.OKBLUE+"]")
|
||||
return False
|
||||
else:
|
||||
service_cmd = ('service {0} start'.format(service_name))
|
||||
@@ -78,12 +81,16 @@ class WOService():
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
output, error_output = sub.communicate()
|
||||
if 'emerg' not in str(error_output):
|
||||
Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]")
|
||||
service_cmd = ('service {0} restart'.format(service_name))
|
||||
retcode = subprocess.getstatusoutput(service_cmd)
|
||||
return True
|
||||
if retcode[0] == 0:
|
||||
Log.info(self, "Restarting Nginx" +
|
||||
"[" + Log.ENDC + "OK" + Log.OKBLUE + "]")
|
||||
return True
|
||||
else:
|
||||
Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]")
|
||||
Log.info(
|
||||
self, "Restarting Nginx" + "[" + Log.FAIL +
|
||||
"Failed" + Log.OKBLUE+"]")
|
||||
return False
|
||||
else:
|
||||
service_cmd = ('service {0} restart'.format(service_name))
|
||||
@@ -113,17 +120,19 @@ class WOService():
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
output, error_output = sub.communicate()
|
||||
if 'emerg' not in str(error_output):
|
||||
service_cmd = ('service {0} restart'.format(service_name))
|
||||
service_cmd = ('service {0} reload'.format(service_name))
|
||||
retcode = subprocess.getstatusoutput(service_cmd)
|
||||
Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]")
|
||||
return True
|
||||
if retcode[0] == 0:
|
||||
Log.info(self, "Reloading Nginx" +
|
||||
"[" + Log.ENDC + "OK" + Log.OKBLUE + "]")
|
||||
return True
|
||||
else:
|
||||
Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]")
|
||||
Log.info(
|
||||
self, "Restarting Nginx" + "[" + Log.FAIL +
|
||||
"Failed" + Log.OKBLUE+"]")
|
||||
return False
|
||||
|
||||
else:
|
||||
service_cmd = ('service {0} reload'.format(service_name))
|
||||
|
||||
Log.info(self, "Reload : {0:10}".format(service_name), end='')
|
||||
retcode = subprocess.getstatusoutput(service_cmd)
|
||||
if retcode[0] == 0:
|
||||
|
||||
Reference in New Issue
Block a user