mirror of
https://git.coolaj86.com/coolaj86/greenlock-cli.js
synced 2025-02-23 11:38:05 +00:00
Fixed standalone server closing, and made the index.js promise resolve only after the standalone server has closed.
This commit is contained in:
parent
248640cd3e
commit
e073b273b3
14
index.js
14
index.js
@ -84,13 +84,13 @@ module.exports.run = function (args) {
|
|||||||
|
|
||||||
if (servers) {
|
if (servers) {
|
||||||
if (args.tlsSni01Port) {
|
if (args.tlsSni01Port) {
|
||||||
servers = servers.startServers(
|
servers.startServers(
|
||||||
[], args.tlsSni01Port
|
[], args.tlsSni01Port
|
||||||
, { debug: args.debug, httpsOptions: le.httpsOptions }
|
, { debug: args.debug, httpsOptions: le.httpsOptions }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
servers = servers.startServers(
|
servers.startServers(
|
||||||
args.http01Port || [80], []
|
args.http01Port || [80], []
|
||||||
, { debug: args.debug }
|
, { debug: args.debug }
|
||||||
);
|
);
|
||||||
@ -117,10 +117,6 @@ module.exports.run = function (args) {
|
|||||||
console.log("Renewing them now");
|
console.log("Renewing them now");
|
||||||
return certs._renewing;
|
return certs._renewing;
|
||||||
}).then(function (certs) {
|
}).then(function (certs) {
|
||||||
if (servers) {
|
|
||||||
servers.closeServers();
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("");
|
console.log("");
|
||||||
console.log("Got certificate(s) for " + certs.altnames.join(', '));
|
console.log("Got certificate(s) for " + certs.altnames.join(', '));
|
||||||
console.log("\tIssued at " + new Date(certs.issuedAt).toISOString() + "");
|
console.log("\tIssued at " + new Date(certs.issuedAt).toISOString() + "");
|
||||||
@ -147,6 +143,12 @@ module.exports.run = function (args) {
|
|||||||
);
|
);
|
||||||
console.log("");
|
console.log("");
|
||||||
|
|
||||||
|
if (servers) {
|
||||||
|
return servers.closeServers({ debug: args.debug }).then(function() {
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
console.error('[Error]: greenlock-cli');
|
console.error('[Error]: greenlock-cli');
|
||||||
|
@ -77,11 +77,27 @@ module.exports.create = function (challenge) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
, closeServers: function () {
|
, closeServers: function (opts) {
|
||||||
|
opts = opts || {};
|
||||||
|
return new Promise(function (done) {
|
||||||
|
var closedServers = 0;
|
||||||
|
var serversToClose = servers._servers.length;
|
||||||
|
if (0 === serversToClose) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
servers._servers.forEach(function (server) {
|
servers._servers.forEach(function (server) {
|
||||||
server.close();
|
server.close(function () {
|
||||||
});
|
if (serversToClose === ++closedServers) {
|
||||||
|
if (opts.debug) {
|
||||||
|
console.info('Closed all servers');
|
||||||
|
}
|
||||||
servers._servers = [];
|
servers._servers = [];
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user