fixed antipatter by using async main func

This commit is contained in:
Luca Wlcek
2023-11-17 18:15:19 +01:00
parent a697b43ac4
commit ac2b959ec6

View File

@@ -230,7 +230,7 @@ const internalNginx = {
* @param {Object} host * @param {Object} host
* @returns {Promise} * @returns {Promise}
*/ */
generateConfig: (host_type, host) => { generateConfig: async (host_type, host) => {
const nice_host_type = internalNginx.getFileFriendlyHostType(host_type); const nice_host_type = internalNginx.getFileFriendlyHostType(host_type);
if (config.debug()) { if (config.debug()) {
@@ -239,15 +239,13 @@ const internalNginx = {
const renderEngine = utils.getRenderEngine(); const renderEngine = utils.getRenderEngine();
return new Promise(async (resolve, reject) => {
let template = null; let template = null;
let filename = internalNginx.getConfigName(nice_host_type, host.id); let filename = internalNginx.getConfigName(nice_host_type, host.id);
try { try {
template = fs.readFileSync(__dirname + '/../templates/' + nice_host_type + '.conf', {encoding: 'utf8'}); template = fs.readFileSync(__dirname + '/../templates/' + nice_host_type + '.conf', {encoding: 'utf8'});
} catch (err) { } catch (err) {
reject(new error.ConfigurationError(err.message)); throw new error.ConfigurationError(err.message);
return;
} }
let locationsPromise; let locationsPromise;
@@ -312,7 +310,7 @@ const internalNginx = {
// Restore locations array // Restore locations array
host.locations = origLocations; host.locations = origLocations;
resolve(true); return true;
}) })
.catch((err) => { .catch((err) => {
if (config.debug()) { if (config.debug()) {
@@ -322,7 +320,6 @@ const internalNginx = {
throw new error.ConfigurationError(err.message); throw new error.ConfigurationError(err.message);
}); });
}); });
});
}, },
/** /**