def _test_http_ngx_cfg(self): LOG.debug('Testing the new nginx configuration') try: utils.execute('nginx -t') except exception.ProcessExecutionError as e: LOG.warn('Did not pass the new nginx configuration test: %s', e) raise
def _reload_http_ngx_cfg(self): LOG.debug('Reloading nginx') try: utils.execute('nginx -s reload') except exception.ProcessExecutionError as e: LOG.warn("Failed to reload nginx " "nginx master process: %s", e) raise
def _create_http_ngx_cfg(self, msg): cfile_path = "/etc/nginx/sites-available/%s" % \ self._conf_file_name(msg) if os.path.exists(cfile_path): raise exception.NginxConfFileExists(path=cfile_path) ngx_cfg = self._create_http_ngx_cfg_buffer(msg) LOG.info('Write it into configuration file: %s', cfile_path) with open(cfile_path, 'w') as cfile: cfile.write(ngx_cfg) cmd = "ln -sf %s /etc/nginx/sites-enabled/" % cfile_path utils.execute(cmd)