Fix errors in acme provisioning (#4648)
* Better logging for errors on startup * Fix "TypeError: '>' not supported" when starting without an existing certificate * Fix a bug where an existing certificate would be reprovisoned every dayrelease-v0.99.1
parent
06cd757ae7
commit
f311018823
|
@ -0,0 +1,2 @@
|
||||||
|
Fix "TypeError: '>' not supported" when starting without an existing certificate.
|
||||||
|
Fix a bug where an existing certificate would be reprovisoned every day.
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright 2014-2016 OpenMarket Ltd
|
# Copyright 2014-2016 OpenMarket Ltd
|
||||||
|
# Copyright 2019 New Vector Ltd
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -14,11 +15,12 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import gc
|
import gc
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
|
||||||
|
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
|
@ -27,6 +29,7 @@ from prometheus_client import Gauge
|
||||||
|
|
||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
from twisted.internet import defer, reactor
|
from twisted.internet import defer, reactor
|
||||||
|
from twisted.python.failure import Failure
|
||||||
from twisted.web.resource import EncodingResourceWrapper, NoResource
|
from twisted.web.resource import EncodingResourceWrapper, NoResource
|
||||||
from twisted.web.server import GzipEncoderFactory
|
from twisted.web.server import GzipEncoderFactory
|
||||||
from twisted.web.static import File
|
from twisted.web.static import File
|
||||||
|
@ -394,10 +397,10 @@ def setup(config_options):
|
||||||
# is less than our re-registration threshold.
|
# is less than our re-registration threshold.
|
||||||
provision = False
|
provision = False
|
||||||
|
|
||||||
if (cert_days_remaining is None):
|
if (
|
||||||
provision = True
|
cert_days_remaining is None or
|
||||||
|
cert_days_remaining < hs.config.acme_reprovision_threshold
|
||||||
if cert_days_remaining > hs.config.acme_reprovision_threshold:
|
):
|
||||||
provision = True
|
provision = True
|
||||||
|
|
||||||
if provision:
|
if provision:
|
||||||
|
@ -438,7 +441,11 @@ def setup(config_options):
|
||||||
hs.get_datastore().start_doing_background_updates()
|
hs.get_datastore().start_doing_background_updates()
|
||||||
except Exception:
|
except Exception:
|
||||||
# Print the exception and bail out.
|
# Print the exception and bail out.
|
||||||
traceback.print_exc(file=sys.stderr)
|
print("Error during startup:", file=sys.stderr)
|
||||||
|
|
||||||
|
# this gives better tracebacks than traceback.print_exc()
|
||||||
|
Failure().printTraceback(file=sys.stderr)
|
||||||
|
|
||||||
if reactor.running:
|
if reactor.running:
|
||||||
reactor.stop()
|
reactor.stop()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -242,3 +242,5 @@ def setup_logging(config, use_worker_options=False):
|
||||||
[_log],
|
[_log],
|
||||||
redirectStandardIO=not config.no_redirect_stdio,
|
redirectStandardIO=not config.no_redirect_stdio,
|
||||||
)
|
)
|
||||||
|
if not config.no_redirect_stdio:
|
||||||
|
print("Redirected stdout/stderr to logs")
|
||||||
|
|
Loading…
Reference in New Issue