fixed antipatter by using async main func
This commit is contained in:
parent
a697b43ac4
commit
ac2b959ec6
1 changed files with 73 additions and 76 deletions
|
@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue