summary refs log tree commit diff
path: root/synapse/app/_base.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Suppress CryptographyDeprecationWarning (#9698)Richard van der Hoff2021-03-261-0/+21
| | | This warning is somewhat confusing to users, so let's suppress it
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-9/+5
| | | | | | | - Update black version to the latest - Run black auto formatting over the codebase - Run autoformatting according to [`docs/code_style.md `](https://github.com/matrix-org/synapse/blob/80d6dc9783aa80886a133756028984dbf8920168/docs/code_style.md) - Update `code_style.md` docs around installing black to use the correct version
* Fixes for PyPy compatibility (#9270)Ivan Shapovalov2021-01-301-1/+2
| | | | | | | | | | | | * synapse.app.base: only call gc.freeze() on CPython gc.freeze() is an implementation detail of CPython garbage collector, and notably does not exist on PyPy. Rather than playing whack-a-mole and skipping the call when under PyPy, simply restrict it to CPython because the whole gc module is implementation-defined. Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
* Clean up exception handling in the startup code (#9059)Richard van der Hoff2021-01-111-59/+91
| | | | Factor out the exception handling in the startup code to a utility function, and fix the some logging and exit code stuff.
* Fix deadlock on SIGHUP (#8918)Erik Johnston2020-12-101-1/+5
| | | Fixes #8892
* Defer SIGHUP handlers to reactor. (#8817)Erik Johnston2020-11-261-1/+9
| | | | | | | | | We can get a SIGHUP at any point, including times where we are not in a sane state. By deferring calling the handlers until the next reactor tick we ensure that we don't get unexpected conflicts, e.g. trying to flush logs from the signal handler while the code was in the process of writing a log entry. Fixes #8769.
* Fix SIGHUP handler (#8697)Richard van der Hoff2020-11-061-3/+2
| | | | | | | Fixes: ``` builtins.TypeError: _reload_logging_config() takes 1 positional argument but 2 were given ```
* Add logging on startup/shutdown (#8448)Erik Johnston2020-10-021-0/+5
| | | | | This is so we can tell what is going on when things are taking a while to start up. The main change here is to ensure that transactions that are created during startup get correctly logged like normal transactions.
* Allow background tasks to be run on a separate worker. (#8369)Patrick Cloke2020-10-021-0/+6
|
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-2/+2
|
* Add a comment about _LimitedHostnameResolverRichard van der Hoff2020-08-291-0/+7
|
* Rename database classes to make some sense (#8033)Erik Johnston2020-08-051-1/+1
|
* re-implement daemonize (#8011)Richard van der Hoff2020-08-041-13/+3
| | | | | | | | | | | | | This has long been something I've wanted to do. Basically the `Daemonize` code is both too flexible and not flexible enough, in that it offers a bunch of features that we don't use (changing UID, closing FDs in the child, logging to syslog) and doesn't offer a bunch that we could do with (redirecting stdout/err to a file instead of /dev/null; having the parent not exit until the child is running). As a first step, I've lifted the Daemonize code and removed the bits we don't use. This should be a non-functional change. Fixing everything else will come later.
* Create a ListenerConfig object (#7681)Richard van der Hoff2020-06-161-3/+5
| | | | | | | | | | This ended up being a bit more invasive than I'd hoped for (not helped by generic_worker duplicating some of the code from homeserver), but hopefully it's an improvement. The idea is that, rather than storing unstructured `dict`s in the config for the listener configurations, we instead parse it into a structured `ListenerConfig` object.
* Fix new flake8 errors (#7470)Erik Johnston2020-05-121-2/+3
|
* Add instance name to RDATA/POSITION commands (#7364)Erik Johnston2020-04-291-2/+2
| | | | | This is primarily for allowing us to send those commands from workers, but for now simply allows us to ignore echoed RDATA/POSITION commands that we sent (we get echoes of sent commands when using redis). Currently we log a WARNING on the master process every time we receive an echoed RDATA.
* Move pusherpool startup into _base.setup (#7104)Richard van der Hoff2020-03-191-0/+1
| | | | | This should be safe to do on all workers/masters because it is guarded by a config option which will ensure it is only actually done on the worker assigned as a pusher.
* Clarify list/set/dict/tuple comprehensions and enforce via flake8 (#6957)Patrick Cloke2020-02-211-1/+1
| | | | Ensure good comprehension hygiene using flake8-comprehensions.
* Freeze allocated objects on startup. (#6953)Erik Johnston2020-02-191-0/+9
| | | | | This may make gc go a bit faster as the gc will know things like caches/data stores etc. are frozen without having to check.
* Fix sdnotify with acme enabled (#6571)Richard van der Hoff2019-12-191-3/+7
| | | | | | | If acme was enabled, the sdnotify startup hook would never be run because we would try to add it to a hook which had already fired. There's no need to delay it: we can sdnotify as soon as we've started the listeners.
* Move DB pool and helper functions into dedicated Database classErik Johnston2019-12-051-1/+1
|
* Fix up some typechecking (#6150)Amber Brown2019-10-021-1/+3
| | | | | | * type checking fixes * changelog
* Implement a structured logging output system. (#5680)Amber Brown2019-08-281-5/+7
|
* Drop dependency on sdnotify (#5871)Richard van der Hoff2019-08-171-10/+37
| | | | | | ... to save OSes which don't use it from having to maintain a port. Fixes #5865.
* Add process hooks to tell systemd our state.Erik Johnston2019-07-221-0/+29
| | | | Fixes #5676.
* Support Prometheus_client 0.4.0+ (#5636)Amber Brown2019-07-181-2/+1
|
* Merge branch 'develop' of github.com:matrix-org/synapse into erikj/admin_api_cmdErik Johnston2019-07-151-29/+34
|\
| * Add basic opentracing support (#5544)Jorik Schellekens2019-07-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Configure and initialise tracer Includes config options for the tracer and sets up JaegerClient. * Scope manager using LogContexts We piggy-back our tracer scopes by using log context. The current log context gives us the current scope. If new scope is created we create a stack of scopes in the context. * jaeger is a dependency now * Carrier inject and extraction for Twisted Headers * Trace federation requests on the way in and out. The span is created in _started_processing and closed in _finished_processing because we need a meaningful log context. * Create logcontext for new scope. Instead of having a stack of scopes in a logcontext we create a new context for a new scope if the current logcontext already has a scope. * Remove scope from logcontext if logcontext is top level * Disable tracer if not configured * typo * Remove dependence on jaeger internals * bools * Set service name * :Explicitely state that the tracer is disabled * Black is the new black * Newsfile * Code style * Use the new config setup. * Generate config. * Copyright * Rename config to opentracing * Remove user whitelisting * Empty whitelist by default * User ConfigError instead of RuntimeError * Use isinstance * Use tag constants for opentracing. * Remove debug comment and no need to explicitely record error * Two errors a "s(c)entry" * Docstrings! * Remove debugging brainslip * Homeserver Whitlisting * Better opentracing config comment * linting * Inclue worker name in service_name * Make opentracing an optional dependency * Neater config retreival * Clean up dummy tags * Instantiate tracing as object instead of global class * Inlcude opentracing as a homeserver member. * Thread opentracing to the request level * Reference opetnracing through hs * Instantiate dummy opentracin g for tests. * About to revert, just keeping the unfinished changes just in case * Revert back to global state, commit number: 9ce4a3d9067bf9889b86c360c05ac88618b85c4f * Use class level methods in tracerutils * Start and stop requests spans in a place where we have access to the authenticated entity * Seen it, isort it * Make sure to close the active span. * I'm getting black and blue from this. * Logger formatting Co-Authored-By: Erik Johnston <erik@matrix.org> * Outdated comment * Import opentracing at the top * Return a contextmanager * Start tracing client requests from the servlet * Return noop context manager if not tracing * Explicitely say that these are federation requests * Include servlet name in client requests * Use context manager * Move opentracing to logging/ * Seen it, isort it again! * Ignore twisted return exceptions on context exit * Escape the scope * Scopes should be entered to make them useful. * Nicer decorator names * Just one init, init? * Don't need to close something that isn't open * Docs make you smarter
| * Move logging utilities out of the side drawer of util/ and into logging/ (#5606)Amber Brown2019-07-041-1/+1
| |
| * Fix 'utime went backwards' errors on daemonization. (#5609)Richard van der Hoff2019-07-031-27/+30
| | | | | | | | | | | | | | | | * Fix 'utime went backwards' errors on daemonization. Fixes #5608 * remove spurious debug
* | Add basic admin cmd appErik Johnston2019-07-021-3/+14
|/
* Drop support for cpu_affinity (#5525)Richard van der Hoff2019-06-221-25/+1
| | | This has no useful purpose on python3, and is generally a source of confusion.
* Run Black. (#5482)Amber Brown2019-06-201-41/+36
|
* Fix dropped logcontexts during high outbound traffic. (#5277)Richard van der Hoff2019-05-291-7/+13
| | | Fixes #5271.
* Limit in flight DNS requestsErik Johnston2019-04-091-1/+82
| | | | | | | This is to work around a bug in twisted where a large number of concurrent DNS requests cause it to tight loop forever. c.f. https://twistedmatrix.com/trac/ticket/9620#ticket
* Correctly handle all command line optionsErik Johnston2019-03-141-6/+12
|
* Merge pull request #4632 from matrix-org/erikj/basic_sentryErik Johnston2019-02-181-0/+30
|\ | | | | Add basic optional sentry.io integration
| * Fixup comments and add warningErik Johnston2019-02-131-3/+3
| |
| * CommentsErik Johnston2019-02-121-0/+8
| |
| * Basic sentry integrationErik Johnston2019-02-121-0/+22
| |
* | Update synapse/app/_base.pyErik Johnston2019-02-131-1/+1
| | | | | | Co-Authored-By: richvdh <1389908+richvdh@users.noreply.github.com>
* | Improve logging around listening servicesRichard van der Hoff2019-02-131-9/+14
| | | | | | | | | | | | | | | | | | I wanted to bring listen_tcp into line with listen_ssl in terms of returning a list of ports, and wanted to check that was a safe thing to do - hence the logging in `refresh_certificate`. Also, pull the 'Synapse now listening' message up to homeserver.py, because it was being duplicated everywhere else.
* | Special-case the default bind_addresses for metrics listenerRichard van der Hoff2019-02-131-3/+2
|/ | | | | turns out it doesn't really support ipv6, so let's hack around that by only listening on ipv4 by default.
* Fix error when loading cert if tls is disabled (#4618)Richard van der Hoff2019-02-121-2/+3
| | | | | | If TLS is disabled, it should not be an error if no cert is given. Fixes #4554.
* Infer no_tls from presence of TLS listenersRichard van der Hoff2019-02-111-1/+1
| | | | | Rather than have to specify `no_tls` explicitly, infer whether we need to load the TLS keys etc from whether we have any TLS-enabled listeners.
* Don't create server contexts when TLS is disabledRichard van der Hoff2019-02-111-0/+5
| | | | we aren't going to use them anyway.
* Logging improvements around TLS certsRichard van der Hoff2019-02-111-4/+2
| | | | | Log which file we're reading keys and certs from, and refactor the code a bit in preparation for other work
* Move ClientTLSOptionsFactory init out of refresh_certificates (#4611)Richard van der Hoff2019-02-111-3/+0
| | | | | It's nothing to do with refreshing the certificates. No idea why it was here.
* ACME Reprovisioning (#4522)Amber Brown2019-02-111-0/+19
|
* Deduplicate some code in synapse.app (#4567)Amber Brown2019-02-081-0/+63
|
* ACME config cleanups (#4525)Richard van der Hoff2019-01-301-21/+1
| | | | | | | | | | | | | | | | * Handle listening for ACME requests on IPv6 addresses the weird url-but-not-actually-a-url-string doesn't handle IPv6 addresses without extra quoting. Building a string which you are about to parse again seems like a weird choice. Let's just use listenTCP, which is consistent with what we do elsewhere. * Clean up the default ACME config make it look a bit more consistent with everything else, and tweak the defaults to listen on port 80. * newsfile
* SIGHUP for TLS cert reloading (#4495)Amber Brown2019-01-301-7/+22
|
* Make workers work on Py3 (#4027)Amber Brown2018-10-131-15/+15
|
* Integrate presence from hotfixes (#3694)Amber Brown2018-08-181-2/+4
|
* run isortAmber Brown2018-07-091-4/+7
|
* Run Prometheus on a different port, optionally. (#3274)Amber Brown2018-05-311-0/+13
|
* Remove logger argument and do not catch replication listenerSilke2017-12-181-6/+7
| | | | Signed-off-by: Silke <silke@slxh.eu>
* Add methods for listening on multiple addressesSilke Hofstra2017-12-171-1/+56
| | | | | | | Add listen_tcp and listen_ssl which implement Twisted's reactor.listenTCP and reactor.listenSSL for multiple addresses. Signed-off-by: Silke Hofstra <silke@slxh.eu>
* replace 'except:' with 'except Exception:'Richard van der Hoff2017-10-231-1/+1
| | | | what could possibly go wrong
* Make 'affinity' package optionalErik Johnston2017-10-021-1/+14
|
* Move quit_with_errorErik Johnston2017-10-021-0/+10
|
* Allow configuration of CPU affinityRichard van der Hoff2017-08-151-1/+8
| | | | | Make it possible to set the CPU affinity in the config file, so that we don't need to remember to do it manually every time.
* Factor out common application startRichard van der Hoff2017-08-151-0/+92
We have 10 copies of this code, and I don't really want to update each one separately.