sysinfo: async'ify
in the process, provision, dyndns, mail, dns also got further asyncified
This commit is contained in:
+10
-24
@@ -57,8 +57,6 @@ const apps = require('./apps.js'),
|
||||
|
||||
const REBOOT_CMD = path.join(__dirname, 'scripts/reboot.sh');
|
||||
|
||||
const domainsGet = util.callbackify(domains.get);
|
||||
|
||||
const NOOP_CALLBACK = function (error) { if (error) debug(error); };
|
||||
|
||||
async function initialize() {
|
||||
@@ -331,35 +329,23 @@ async function renewCerts(options, auditSource) {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
function setupDnsAndCert(subdomain, domain, auditSource, progressCallback, callback) {
|
||||
async function setupDnsAndCert(subdomain, domain, auditSource, progressCallback) {
|
||||
assert.strictEqual(typeof subdomain, 'string');
|
||||
assert.strictEqual(typeof domain, 'string');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
assert.strictEqual(typeof progressCallback, 'function');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
domainsGet(domain, function (error, domainObject) {
|
||||
if (error) return callback(error);
|
||||
const domainObject = await domains.get(domain);
|
||||
const dashboardFqdn = dns.fqdn(subdomain, domainObject);
|
||||
|
||||
const dashboardFqdn = dns.fqdn(subdomain, domainObject);
|
||||
const ip = await sysinfo.getServerIp();
|
||||
|
||||
sysinfo.getServerIp(function (error, ip) {
|
||||
if (error) return callback(error);
|
||||
|
||||
async.series([
|
||||
(done) => { progressCallback({ message: `Updating DNS of ${dashboardFqdn}` }); done(); },
|
||||
dns.upsertDnsRecords.bind(null, subdomain, domain, 'A', [ ip ]),
|
||||
(done) => { progressCallback({ message: `Waiting for DNS of ${dashboardFqdn}` }); done(); },
|
||||
dns.waitForDnsRecord.bind(null, subdomain, domain, 'A', ip, { interval: 30000, times: 50000 }),
|
||||
(done) => { progressCallback({ message: `Getting certificate of ${dashboardFqdn}` }); done(); },
|
||||
reverseProxy.ensureCertificate.bind(null, dns.fqdn(subdomain, domainObject), domain, auditSource)
|
||||
], function (error) {
|
||||
if (error) return callback(error);
|
||||
|
||||
callback(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
progressCallback({ message: `Updating DNS of ${dashboardFqdn}` });
|
||||
await dns.upsertDnsRecords(subdomain, domain, 'A', [ ip ]);
|
||||
progressCallback({ message: `Waiting for DNS of ${dashboardFqdn}` });
|
||||
await dns.waitForDnsRecord(subdomain, domain, 'A', ip, { interval: 30000, times: 50000 });
|
||||
progressCallback({ message: `Getting certificate of ${dashboardFqdn}` });
|
||||
await reverseProxy.ensureCertificate(dns.fqdn(subdomain, domainObject), domain, auditSource);
|
||||
}
|
||||
|
||||
async function syncDnsRecords(options) {
|
||||
|
||||
Reference in New Issue
Block a user