blanketed out annoying debug statements, added code to allow for a custom nginx host name

This commit is contained in:
Ronny Abraham 2019-08-07 04:18:59 +03:00
parent 0f94909568
commit 0d68ef122d
2 changed files with 55 additions and 38 deletions

View file

@ -120,9 +120,9 @@ def add_template(dataobject, layout, config, section, template_name="conf"):
# dataobject.templates.section.tname.src # dataobject.templates.section.tname.src
# dataobject.templates.section.tname.dst # dataobject.templates.section.tname.dst
if env.debug: # if env.debug:
# logger = loggify('intialize', 'add_template') # # logger = loggify('intialize', 'add_template')
debug_section = "DEBUG initialize.add_templates[%s]" % section # debug_section = "DEBUG initialize.add_templates[%s]" % section
if not hasattr(dataobject.templates, section): if not hasattr(dataobject.templates, section):
dataobject.templates.addbranch(section) dataobject.templates.addbranch(section)
@ -143,25 +143,28 @@ def add_template(dataobject, layout, config, section, template_name="conf"):
var_section_source = layout['templates'][section][template_name]['source'] var_section_source = layout['templates'][section][template_name]['source']
var_section_output = layout['templates'][section][template_name]['output'] var_section_output = layout['templates'][section][template_name]['output']
if env.debug and section == 'nginx': # debug statements
print("%s -- var_section_path: %s" % (debug_section, var_section_path)) #
print("%s -- var_section_source: %s" % # if env.debug and section == 'nginx':
(debug_section, var_section_source)) # print("%s -- var_section_path: %s" % (
# debug_section, var_section_path))
# print("%s -- var_section_source: %s" %
# (debug_section, var_section_source))
print("%s -- templates in config: %s" % # print("%s -- templates in config: %s" %
(debug_section, 'templates' in config)) # (debug_section, 'templates' in config))
print("%s -- nginx in config: %s" % # print("%s -- nginx in config: %s" %
(debug_section, 'nginx' in config)) # (debug_section, 'nginx' in config))
if 'nginx' in config: # if 'nginx' in config:
print("%s -- ssl in config[nginx]: %s" % # print("%s -- ssl in config[nginx]: %s" %
(debug_section, 'ssl' in config['nginx'])) # (debug_section, 'ssl' in config['nginx']))
print("%s -- port in config[nginx]: %s" % # print("%s -- port in config[nginx]: %s" %
(debug_section, 'port' in config['nginx'])) # (debug_section, 'port' in config['nginx']))
if 'templates' in config: # if 'templates' in config:
print("%s -- templates in config" % debug_section) # print("%s -- templates in config" % debug_section)
if 'templates' in config and section in config['templates']: if 'templates' in config and section in config['templates']:
_config = config['templates'][section] _config = config['templates'][section]
@ -169,8 +172,10 @@ def add_template(dataobject, layout, config, section, template_name="conf"):
var_section_source = _config[template_name]['source'] var_section_source = _config[template_name]['source']
var_section_output = _config[template_name]['output'] var_section_output = _config[template_name]['output']
if env.debug: # debug statements
print("%s -- breakpoint 2" % debug_section) #
# if env.debug:
# print("%s -- breakpoint 2" % debug_section)
# define the local, and dest paths # define the local, and dest paths
_template.path.local = os.path.join( _template.path.local = os.path.join(
@ -189,12 +194,14 @@ def add_template(dataobject, layout, config, section, template_name="conf"):
conf_template.src = var_section_source conf_template.src = var_section_source
conf_template.dst = var_section_output conf_template.dst = var_section_output
if env.debug: # debug statements
print("%s -- template_name: %s" % (debug_section, template_name)) #
print("%s -- conf_template.src: %s" % # if env.debug:
(debug_section, conf_template.src)) # print("%s -- template_name: %s" % (debug_section, template_name))
print("%s -- conf_template.dst: %s" % # print("%s -- conf_template.src: %s" %
(debug_section, conf_template.dst)) # (debug_section, conf_template.src))
# print("%s -- conf_template.dst: %s" %
# (debug_section, conf_template.dst))
def get_config(branchname): def get_config(branchname):
@ -393,20 +400,26 @@ def get_config(branchname):
dataobject.server.nginx.port = config['nginx']['port'] dataobject.server.nginx.port = config['nginx']['port']
dataobject.server.nginx.socket = config['nginx']['socket'] dataobject.server.nginx.socket = config['nginx']['socket']
if 'ssl' in config['nginx']:
dataobject.server.nginx.addbranch('ssl')
dataobject.server.nginx.ssl.servername = \
config['nginx']['ssl_server_name']
dataobject.server.nginx.ssl.serverext = \
config['nginx']['ssl_server_ext']
print("DEBUG -- socket: %s" % dataobject.server.nginx.socket) print("DEBUG -- socket: %s" % dataobject.server.nginx.socket)
if config['project']['host'] == "localhost": if 'host' in config['nginx']:
# if we specificed a host name in the
# configuration file under 'nginx'
# dataobject.server.nginx.addbranch('ssl')
# dataobject.server.nginx.ssl.host = \
# config['nginx']['ssl']['host']
dataobject.server.nginx.host = \
config['nginx']['host']
elif config['project']['host'] == "localhost":
# if localhost, then create a nginx appropriate name based on
# the project name and the extension
dataobject.server.nginx.host = "{projectname}.{ext}".format( dataobject.server.nginx.host = "{projectname}.{ext}".format(
ext=dataobject.project.extension, ext=dataobject.project.extension,
projectname=dataobject.project.name) projectname=dataobject.project.name)

View file

@ -91,6 +91,10 @@ def edit(param='help'):
'path': configuration.logging.nginx.access, 'path': configuration.logging.nginx.access,
'desc': "nginx access log file", 'desc': "nginx access log file",
}, },
'log.nginx.error': {
'path': '/var/log/nginx/error.log',
'desc': "nginx main error file"
},
} }
if param in locations.keys(): if param in locations.keys():