Always generate nginx config for webadmin

Part of #406
This commit is contained in:
Girish Ramakrishnan
2017-08-28 21:00:29 -07:00
parent 61f7c1af48
commit f9706d6a05
2 changed files with 22 additions and 12 deletions

View File

@@ -236,24 +236,32 @@ function configureWebadmin(callback) {
callback(error);
}
sysinfo.getPublicIp(function (error, ip) {
if (error) return done(error);
function configureNginx(error) {
debug('configureNginx: dns update:%j', error);
addDnsRecords(ip, function (error) {
certificates.ensureCertificate({ location: constants.ADMIN_LOCATION }, function (error, certFilePath, keyFilePath) {
if (error) return done(error);
gWebadminStatus.tls = true;
nginx.configureAdmin(certFilePath, keyFilePath, constants.NGINX_ADMIN_CONFIG_FILE_NAME, config.adminFqdn(), done);
});
}
// update the DNS. configure nginx regardless of whether it succeeded so that
// box is accessible even if dns creds are invalid
sysinfo.getPublicIp(function (error, ip) {
if (error) return configureNginx(error);
addDnsRecords(ip, function (error) {
if (error) return configureNginx(error);
subdomains.waitForDns(config.adminFqdn(), ip, 'A', { interval: 30000, times: 50000 }, function (error) {
if (error) return done(error);
if (error) return configureNginx(error);
gWebadminStatus.dns = true;
certificates.ensureCertificate({ location: constants.ADMIN_LOCATION }, function (error, certFilePath, keyFilePath) {
if (error) return done(error);
gWebadminStatus.tls = true;
nginx.configureAdmin(certFilePath, keyFilePath, constants.NGINX_ADMIN_CONFIG_FILE_NAME, config.adminFqdn(), done);
});
configureNginx();
});
});
});