Docker: supervisord 没有启动 uwsgi

Docker: supervisord doesn't start uwsgi

Dockerfile

FROM ubuntu:14.04.2
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get -y update && apt-get upgrade -y
RUN apt-get install supervisor python build-essential python-dev python-pip python-setuptools -y
RUN apt-get install libxml2-dev libxslt1-dev python-dev -y
RUN apt-get install libpq-dev postgresql-common postgresql-client -y
RUN apt-get install openssl openssl-blacklist openssl-blacklist-extra -y
RUN apt-get install nginx -y
RUN pip install "pip>=7.0"
RUN pip install virtualenv uwsgi

RUN mkdir -p /var/log/supervisor
ADD configs/new-canon/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ADD canonicaliser_api /home/ubuntu/canonicaliser_api
ADD config_local.py /home/ubuntu/canonicaliser_api/config/config_local.py
RUN virtualenv /home/ubuntu/canonicaliser_api/venv
RUN source /home/ubuntu/canonicaliser_api/venv/bin/activate && pip install -r /home/ubuntu/canonicaliser_api/requirements.txt
RUN export CFLAGS=-I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include/
RUN source /home/ubuntu/canonicaliser_api/venv/bin/activate && cd /home/ubuntu/canonicaliser_api/canonicaliser/cython_extensions/ && python setup.py build_ext --inplace
RUN cp /home/ubuntu/canonicaliser_api/canonicaliser/cython_extensions/canonicaliser/cython_extensions/*.so /home/ubuntu/canonicaliser_api/canonicaliser/cython_extensions
RUN rm -rf /home/ubuntu/canonicaliser_api/canonicaliser/cython_extensions/canonicaliser
RUN rm -r /home/ubuntu/canonicaliser_api/canonicaliser/cython_extensions/build

RUN mkdir /var/run/flask-uwsgi
RUN chown -R www-data:www-data /var/run/flask-uwsgi
# RUN chown -R www-data:www-data /home/ubuntu/canonicaliser_api
RUN mkdir /var/log/flask-uwsgi
RUN touch /var/log/flask-uwsgi/dqs_canon.log
RUN chown -R www-data:www-data /var/log/flask-uwsgi
RUN mkdir /etc/flask-uwsgi

ADD configs/new-canon/flask-uwsgi/flask-uwsgi.conf /etc/init/
ADD configs/new-canon/flask-uwsgi/flask-uwsgi.ini /etc/flask-uwsgi/

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
EXPOSE 8888
#CMD uwsgi --ini /etc/flask-uwsgi/flask-uwsgi.ini
CMD ["/usr/bin/supervisord"]

主管:

[supervisord]
nodaemon=true

[program:flask-uwsgi]
command=/bin/bash -c "exec uwsgi --ini /etc/flask-uwsgi/flask-uwsgi.ini -DFOREGROUND"

flask-uwsgi.ini:

[uwsgi]
chdir = /home/ubuntu/canonicaliser_api
socket = /var/run/flask-uwsgi/flask-uwsgi.sock
home = /home/ubuntu/canonicaliser_api/venv
wsgi-file = /home/ubuntu/canonicaliser_api/flask_uwsgi.py
callable = app
master = true
; www-data uid/gid
uid = 33
gid = 33
http-socket = :8888
die-on-term = true
processes = 4
threads = 2
logger = file:/var/log/flask-uwsgi/flask-uwsgi.log

错误信息:

bash-3.2$ docker run -p 8888:8888 canon
/usr/lib/python2.7/dist-packages/supervisor/options.py:295: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
  'Supervisord is running as root and it is searching '
2015-08-06 11:27:42,590 CRIT Supervisor running as root (no user in config file)
2015-08-06 11:27:42,591 WARN Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
2015-08-06 11:27:42,625 INFO RPC interface 'supervisor' initialized
2015-08-06 11:27:42,625 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2015-08-06 11:27:42,625 INFO supervisord started with pid 1
2015-08-06 11:27:43,629 INFO spawned: 'flask-uwsgi' with pid 7
2015-08-06 11:27:43,666 INFO exited: flask-uwsgi (exit status 1; not expected)
2015-08-06 11:27:44,671 INFO spawned: 'flask-uwsgi' with pid 8
2015-08-06 11:27:44,678 INFO exited: flask-uwsgi (exit status 1; not expected)
2015-08-06 11:27:46,687 INFO spawned: 'flask-uwsgi' with pid 9
2015-08-06 11:27:46,694 INFO exited: flask-uwsgi (exit status 1; not expected)
2015-08-06 11:27:49,707 INFO spawned: 'flask-uwsgi' with pid 10
2015-08-06 11:27:49,713 INFO exited: flask-uwsgi (exit status 1; not expected)
2015-08-06 11:27:50,715 INFO gave up: flask-uwsgi entered FATAL state, too many start retries too quickly

如果我 运行 这个喜欢,它工作正常。所以它不会是坏的uwsgi设置:

CMD uwsgi --ini /etc/flask-uwsgi/flask-uwsgi.ini

我认为您只需要提供完整路径并删除 -DFOREGROUND(这不是 uwsgi 标志)。尝试:

command=/usr/local/bin/uwsgi --ini /etc/flask-uwsgi/flask-uwsgi.ini