mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Run renews sequentially
This commit is contained in:
parent
fe4bd9fed6
commit
f7d1c490b3
@ -30,7 +30,7 @@ const internalCertificate = {
|
|||||||
intervalTimeout: 1000 * 60 * 60, // 1 hour
|
intervalTimeout: 1000 * 60 * 60, // 1 hour
|
||||||
interval: null,
|
interval: null,
|
||||||
intervalProcessing: false,
|
intervalProcessing: false,
|
||||||
renewBeforeExpirationBy: [7, 'days'],
|
renewBeforeExpirationBy: [30, 'days'],
|
||||||
|
|
||||||
initTimer: () => {
|
initTimer: () => {
|
||||||
logger.info('Let\'s Encrypt Renewal Timer initialized');
|
logger.info('Let\'s Encrypt Renewal Timer initialized');
|
||||||
@ -49,7 +49,7 @@ const internalCertificate = {
|
|||||||
|
|
||||||
const expirationThreshold = moment().add(internalCertificate.renewBeforeExpirationBy[0], internalCertificate.renewBeforeExpirationBy[1]).format('YYYY-MM-DD HH:mm:ss');
|
const expirationThreshold = moment().add(internalCertificate.renewBeforeExpirationBy[0], internalCertificate.renewBeforeExpirationBy[1]).format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
|
||||||
// Fetch all the letsencrypt certs from the db that will expire within 7 days
|
// Fetch all the letsencrypt certs from the db that will expire within N days
|
||||||
certificateModel
|
certificateModel
|
||||||
.query()
|
.query()
|
||||||
.where('is_deleted', 0)
|
.where('is_deleted', 0)
|
||||||
@ -60,28 +60,32 @@ const internalCertificate = {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let promises = [];
|
/**
|
||||||
|
* Renews must be run sequentially or we'll get an error 'Another
|
||||||
|
* instance of Certbot is already running.'
|
||||||
|
*/
|
||||||
|
let sequence = Promise.resolve();
|
||||||
|
|
||||||
certificates.forEach(function (certificate) {
|
certificates.forEach(function (certificate) {
|
||||||
const promise = internalCertificate
|
sequence = sequence.then(() =>
|
||||||
.renew(
|
internalCertificate
|
||||||
{
|
.renew(
|
||||||
can: () =>
|
{
|
||||||
Promise.resolve({
|
can: () =>
|
||||||
permission_visibility: 'all',
|
Promise.resolve({
|
||||||
}),
|
permission_visibility: 'all',
|
||||||
},
|
}),
|
||||||
{ id: certificate.id },
|
},
|
||||||
)
|
{ id: certificate.id },
|
||||||
.catch((err) => {
|
)
|
||||||
// Don't want to stop the train here, just log the error
|
.catch((err) => {
|
||||||
logger.error(err.message);
|
// Don't want to stop the train here, just log the error
|
||||||
});
|
logger.error(err.message);
|
||||||
|
}),
|
||||||
promises.push(promise);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.all(promises);
|
return sequence;
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
internalCertificate.intervalProcessing = false;
|
internalCertificate.intervalProcessing = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user