Python 码头上的Gunicorn在Mac上出错
我只在Mac上收到以下错误。它在Linux主机上运行良好: 输出:Python 码头上的Gunicorn在Mac上出错,python,docker,gunicorn,Python,Docker,Gunicorn,我只在Mac上收到以下错误。它在Linux主机上运行良好: 输出: FileNotFoundError: [Errno 2] No such file or directory server_1 | [2019-10-22 22:48:39 +0000] [397] [INFO] Worker exiting (pid: 397) server_1 | [2019-10-22 22:48:39 +0000] [412] [INFO] Booting worker with pid: 412
FileNotFoundError: [Errno 2] No such file or directory
server_1 | [2019-10-22 22:48:39 +0000] [397] [INFO] Worker exiting (pid: 397)
server_1 | [2019-10-22 22:48:39 +0000] [412] [INFO] Booting worker with pid: 412
server_1 | [2019-10-22 22:48:39 +0000] [413] [INFO] Booting worker with pid: 413
server_1 | /usr/local/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
server_1 | """)
server_1 | [2019-10-22 22:48:40 +0000] [404] [ERROR] Exception in worker process
server_1 | Traceback (most recent call last):
server_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
server_1 | worker.init_process()
server_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 134, in init_process
server_1 | self.run()
server_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 124, in run
server_1 | self.run_for_one(timeout)
server_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 61, in run_for_one
server_1 | self.notify()
server_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 69, in notify
server_1 | self.tmp.notify()
server_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/workertmp.py", line 43, in notify
server_1 | os.fchmod(self._tmp.fileno(), self.spinner)
server_1 | FileNotFoundError: [Errno 2] No such file or directory
server_1 | [2019-10-22 22:48:40 +0000] [404] [INFO] Worker exiting (pid: 404)
server_1 | [2019-10-22 22:48:40 +0000] [420] [INFO] Booting worker with pid: 420
命令:
docker-compose build
docker-compose -f docker-compose.yml -f docker-compose.override.mac.yml up
Dockerfile:
FROM library/python:3.7-stretch
RUN apt-get update && apt-get install -y python3 python3-pip \
postgresql-client \
# TODO - Might not need this any longer with GridLAB-D on its own container
# GridLAB-D requires this library
# libxerces-c-dev \
# For VIM
apt-file \
vim \
#for Docker (spin up another Docker container sibling from inside this container)
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common \
#python3-distutils
python-distutils-extra
#RUN yes | apt-get install rabbitmq-server
# Install Docker, to be able to run sibling docker containers
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
RUN apt-get update
RUN apt-get install -y --allow-unauthenticated docker-ce
RUN yes | apt-get install netcat
#RUN docker run hello-world
RUN lsb_release -cs
RUN pip install --upgrade pip
WORKDIR /gripcode
# TODO: Switch from fork to main glm-plotter after changes get merged
# When switching, make sure to commment/uncomment out the clone in the start.sh
# Force cache to be invalidated for this GitHub repo
ARG USER=presencepg
ARG REPO=glm-plotter
ARG BRANCH=master
# TODO: Increase the rate limit of 60 per hour for unauthenticated requests: https://developer.github.com/v3/#rate-limiting
ADD https://api.github.com/repos/${USER}/${REPO}/git/refs/heads/${BRANCH} version.json
RUN pip3 install git+https://github.com/${USER}/glm-plotter.git
# TODO: Just copy the template and static files here (and take out the clone from the start.sh)
# RUN pip3 install git+https://github.com/jdechalendar/glm-plotter.git
############################################
COPY requirements.txt /
ARG CACHEBUST=1
RUN pip3 install --trusted-host pypi.org -r /requirements.txt
WORKDIR /gripcode
ARG GRIP_ENVSET
ENV GRIP_ENV $GRIP_ENVSET
CMD ["./bin/docker_start.sh"]
将Docker卷用于worker temp目录时出现问题。解释解决方案,即使用
--worker tmp dir
指定卷外的目录。在我的例子中,我做了类似于--worker tmp dir/gunicorn worker tmp dir
的操作,它指向我在卷外部的Docker映像内创建的本地目录。将Docker卷用于worker temp目录存在问题。解释解决方案,即使用--worker tmp dir
指定卷外的目录。在我的例子中,我做了类似于--worker tmp dir/gunicorn worker tmp dir
,它指向我在卷之外的Docker映像中创建的本地目录。你的问题是什么?您是否试图了解错误及其原因?丢失了什么文件?您提供的文件在哪里使用了它?@rok,我的问题是‘是什么导致了这个错误?’我不知道丢失了什么文件。错误消息不太清楚。您确实希望尝试将其减少为一个错误消息。期望我们重新创建一个复杂的设置,以便我们可以开始调查错误消息的原因,这是不现实的。查看是否可以从Docker映像中提取其他日志文件,和/或增加日志记录的详细程度,以便实际报告根本原因(可能需要获得正确的回溯)?同时装载/tmp
和/tmp/gunicorn.sock
看起来很奇怪,但我不知道这是否与此相关。@triplee,我想我可以在使用主机网络时删除它们。我甚至不确定何时需要/tmp/gunicorn.sock。你的问题是什么?您是否试图了解错误及其原因?丢失了什么文件?您提供的文件在哪里使用了它?@rok,我的问题是‘是什么导致了这个错误?’我不知道丢失了什么文件。错误消息不太清楚。您确实希望尝试将其减少为一个错误消息。期望我们重新创建一个复杂的设置,以便我们可以开始调查错误消息的原因,这是不现实的。查看是否可以从Docker映像中提取其他日志文件,和/或增加日志记录的详细程度,以便实际报告根本原因(可能需要获得正确的回溯)?同时装载/tmp
和/tmp/gunicorn.sock
看起来很奇怪,但我不知道这是否与此相关。@triplee,我想我可以在使用主机网络时删除它们。我甚至不确定何时需要/tmp/gunicorn.sock。
docker-compose build
docker-compose -f docker-compose.yml -f docker-compose.override.mac.yml up
FROM library/python:3.7-stretch
RUN apt-get update && apt-get install -y python3 python3-pip \
postgresql-client \
# TODO - Might not need this any longer with GridLAB-D on its own container
# GridLAB-D requires this library
# libxerces-c-dev \
# For VIM
apt-file \
vim \
#for Docker (spin up another Docker container sibling from inside this container)
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common \
#python3-distutils
python-distutils-extra
#RUN yes | apt-get install rabbitmq-server
# Install Docker, to be able to run sibling docker containers
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
RUN apt-get update
RUN apt-get install -y --allow-unauthenticated docker-ce
RUN yes | apt-get install netcat
#RUN docker run hello-world
RUN lsb_release -cs
RUN pip install --upgrade pip
WORKDIR /gripcode
# TODO: Switch from fork to main glm-plotter after changes get merged
# When switching, make sure to commment/uncomment out the clone in the start.sh
# Force cache to be invalidated for this GitHub repo
ARG USER=presencepg
ARG REPO=glm-plotter
ARG BRANCH=master
# TODO: Increase the rate limit of 60 per hour for unauthenticated requests: https://developer.github.com/v3/#rate-limiting
ADD https://api.github.com/repos/${USER}/${REPO}/git/refs/heads/${BRANCH} version.json
RUN pip3 install git+https://github.com/${USER}/glm-plotter.git
# TODO: Just copy the template and static files here (and take out the clone from the start.sh)
# RUN pip3 install git+https://github.com/jdechalendar/glm-plotter.git
############################################
COPY requirements.txt /
ARG CACHEBUST=1
RUN pip3 install --trusted-host pypi.org -r /requirements.txt
WORKDIR /gripcode
ARG GRIP_ENVSET
ENV GRIP_ENV $GRIP_ENVSET
CMD ["./bin/docker_start.sh"]