Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How could I ignore all the hypercorn output? #192

Open
rafaelcapucho opened this issue Feb 20, 2024 · 3 comments
Open

How could I ignore all the hypercorn output? #192

rafaelcapucho opened this issue Feb 20, 2024 · 3 comments

Comments

@rafaelcapucho
Copy link

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
@rafaelcapucho
Copy link
Author

rafaelcapucho commented Feb 20, 2024

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

@TinajaStyle
Copy link

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

@pgjones
Copy link
Owner

pgjones commented May 27, 2024

I think there is something odd here, unless you tell Hypercorn where to access log to (- being sysout) it won't. Are you sure it is access logs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants