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