1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-08-10 22:31:47 +02:00
3044: Add a sigterm handler to make docker stop go faster r=mergify[bot] a=nextgens

## What type of PR?

enhancement

## What does this PR do?

- Add a sigterm handler to make ``docker stop`` go way faster
- Ensure we don't log requests to /ping in admin
- Fixup doc
- Upgrade WTForms to fix alias creation

### Related issue(s)

## Prerequisites
Before we can consider review and merge, please make sure the following list is done and checked.
If an entry in not applicable, you can check it or remove it from the list.

- [ ] In case of feature or enhancement: documentation updated accordingly
- [ ] Unless it's docs or a minor change: add [changelog](https://mailu.io/master/contributors/workflow.html#changelog) entry file.


Co-authored-by: Florent Daigniere <nextgens@freenetproject.org>
Co-authored-by: Florent Daigniere <nextgens@users.noreply.github.com>
This commit is contained in:
bors-mailu[bot]
2023-11-14 19:10:40 +00:00
committed by GitHub
4 changed files with 11 additions and 5 deletions

View File

@@ -12,7 +12,7 @@ import hmac
class NoPingFilter(logging.Filter):
def filter(self, record):
if (record.args['{host}i'] == 'localhost' and record.args['r'] == 'GET /ping HTTP/1.1'):
if record.args['r'].endswith(' /ping HTTP/1.1'):
return False
if record.args['r'].endswith(' /internal/rspamd/local_domains HTTP/1.1'):
return False

View File

@@ -1,6 +1,7 @@
import hmac
import logging as log
import os
import signal
import sys
import re
from pwd import getpwnam
@@ -69,11 +70,17 @@ def _is_compatible_with_hardened_malloc():
return False
return True
def sigterm_handler(_signo, _stack_frame):
log.critical("Received SIGTERM, terminating.")
sys.exit(143)
def set_env(required_secrets=[], log_filters=[]):
if log_filters:
sys.stdout = LogFilter(sys.stdout, log_filters)
sys.stderr = LogFilter(sys.stderr, log_filters)
log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", 'WARNING'))
signal.signal(signal.SIGTERM, sigterm_handler)
if not 'LD_PRELOAD' in os.environ and _is_compatible_with_hardened_malloc():
log.warning('Your CPU has Advanced Vector Extensions available, we recommend you enable hardened-malloc earlier in the boot process by adding LD_PRELOAD=/usr/lib/libhardened_malloc.so to your mailu.env')

View File

@@ -87,7 +87,7 @@ vobject==0.9.6.1
watchdog==3.0.0
Werkzeug===2.3.7
wrapt==1.15.0
WTForms==3.1.0
WTForms==3.1.1
WTForms-Components==0.10.5
xmltodict==0.13.0
yarl==1.9.2