Gunicorn 连接错误,IsADirectoryError: [Errno 21] Is a directory

问题描述 投票:0回答:0

我刚刚创建了我的后端 api,我在其中使用 gunicorn 及其对 HTTPS 证书的支持。在我的

gunicorn.conf.py
中有这些代码:

from multiprocessing import cpu_count
from os import environ

# Server Socket
bind = '0.0.0.0:' + environ.get('PORT', '443')
max_requests = 1000
workers = cpu_count()
timeout = 30

# Logging
loglevel ='info'
accessformat = '%(t)s %(h)s %(l)s %(r)s %(s)s %(b)s %(f)s %(a)s'
accesslog = '-'
errorlog = '-'

# SSL
certfile = "/api/fullchain.pem"
keyfile = "/api/privkey.pem"

虽然在我的 docker-comose 文件中,代码是:

version: "3.9"

services:
  db: 
    container_name: my_table_postgres
    image: postgres
    ports:
      - 5432/tcp
    volumes:
      - my_table_postgres_db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=my_table_postgres
      - POSTGRES_USER=dev
      - POSTGRES_PASSWORD=Ieyh5&RIR48!&8fc

  redis: 
    container_name: redis
    image: redis
    ports:
      - 6739:6739/tcp
    environment:
      - REDIS_HOST=redis-oauth-user-service
    volumes:
      - redis_data:/var/lib/redis/data/

  my_table:
    container_name: my_table
    build: .
    command: ["python", "-m", "gunicorn", "--bind", "0.0.0.0:5000", "-c", "gunicorn.conf.py", "mytable.wsgi"]
    volumes:
      - .:/api
      - ./fullchain.pem:/etc/letsencrypt/live/api.my-table.it/fullchain.pem
      - ./privkey.pem:/etc/letsencrypt/live/api.my-table.it/privkey.pem
    ports:
      - "5000:5000"
    depends_on:
      - db
      - redis

  celery:
    image: celery
    container_name: celery
    restart: unless-stopped
    build:
      context: .
      dockerfile: Dockerfile
    command: ['python', '-m', 'celery', '-A', 'mytable' ,'worker', '-l', 'INFO']
    volumes:
      - .:/api
    depends_on:
      - redis
      - my_table
    links:
      - redis

  nginx:
    build: ./nginx
    ports:
      - "8000:80"
    depends_on:
      - my_table

volumes:
  my_table_postgres_db:
  redis_data:

此时,我对 API 进行以下调用:

http://api.my-table.it:5000/api/v1/restaurant/

这个错误出现在控制台

my_table    | [2023-03-01 07:23:41 +0100] [8] [ERROR] Socket error processing request.
my_table    | Traceback (most recent call last):
my_table    |   File "/home/devuser/.local/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 131, in handle
my_table    |     client = ssl.wrap_socket(client, server_side=True,
my_table    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
my_table    |   File "/usr/local/lib/python3.11/ssl.py", line 1443, in wrap_socket
my_table    |     context.load_cert_chain(certfile, keyfile)
my_table    | IsADirectoryError: [Errno 21] Is a directory

有人能告诉我这是什么意思,并希望如何解决? 因为好像那是不依赖于我的东西

python ssl gunicorn
© www.soinside.com 2019 - 2024. All rights reserved.