How could I ignore all the hypercorn output?
rafaelcapucho opened this issue · comments
The server printing to stdout every single request consuming a lot of resources inside the docker volume pretty fast, I would like to disable the Hypercorn output as much as possible, I tried using > /dev/null
and 2>&1 /dev/null
:
services:
app:
restart: always
build: ./app
ports:
- 5000:5000
volumes:
- ./app:/www/site:rw,z
command: hypercorn --bind '0.0.0.0:5000' --reload main:app 2>&1 /dev/null
but it fails saying that it isn't recognized by hypercorn:
hypercorn: error: unrecognized arguments: 2>&1 /dev/null
usage: hypercorn [-h] [--access-log ACCESS_LOG]
[--access-logfile ACCESS_LOGFILE]
[--access-logformat ACCESS_LOGFORMAT] [--backlog BACKLOG]
[-b BINDS] [--ca-certs CA_CERTS] [--certfile CERTFILE]
[--cert-reqs CERT_REQS] [--ciphers CIPHERS] [-c CONFIG]
[--debug] [--error-log ERROR_LOG]
[--error-logfile ERROR_LOGFILE]
[--graceful-timeout GRACEFUL_TIMEOUT]
[--read-timeout READ_TIMEOUT] [--max-requests MAX_REQUESTS]
[--max-requests-jitter MAX_REQUESTS_JITTER] [-g GROUP]
[-k WORKER_CLASS] [--keep-alive KEEP_ALIVE]
[--keyfile KEYFILE] [--keyfile-password KEYFILE_PASSWORD]
[--insecure-bind INSECURE_BINDS] [--log-config LOG_CONFIG]
[--log-level LOG_LEVEL] [-p PID] [--quic-bind QUIC_BINDS]
[--reload] [--root-path ROOT_PATH]
[--server-name SERVER_NAMES] [--statsd-host STATSD_HOST]
[--statsd-prefix STATSD_PREFIX] [-m UMASK] [-u USER]
[--verify-mode VERIFY_MODE]
[--websocket-ping-interval WEBSOCKET_PING_INTERVAL]
[-w WORKERS]
application
I also tried --access-logfile=/dev/null
but it didn't stop the printing to the stdout.
Dockerfile:
FROM python:3.12-alpine
WORKDIR /www/site
RUN apk update && apk add --virtual build-deps gcc python3-dev musl-dev
RUN python -m pip install --upgrade pip
COPY requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt
RUN apk del build-deps
I tried to set the log-level, but it keeps printing [INFO] lines:
command: hypercorn --bind '0.0.0.0:5000' --reload --log-level=ERROR main:app
I also tried setting --access-logfile
to an empty value:
command: hypercorn --bind '0.0.0.0:5000' --reload --access-logfile= main:app
I think it is better (it works for me) to put all the hypercorn configuration in main, and then run it with python3 and redirect the stderr and stdout to /dev/null:
python3 main.py &>/dev/null