Я знаю, что это обычная проблема, но из-за того, что я искал уже 3 часа, и учитывая, что должна быть задействована квантовая сингулярность, мне пришлось опубликовать это.
Я все время получаю эту знакомую ошибку:
[uWSGI] getting INI configuration from uwsgi.ini,
*** Starting uWSGI 2.0.18-debian (64bit) on [Mon May 25 15:56:04 2020] ***,
compiled with version: 8.2.0 on 10 February 2019 02:42:46,
os: Linux-5.6.12-1-MANJARO #1 SMP PREEMPT Sun May 10 14:36:43 UTC 2020,
nodename: a43c6a7bbb2c,
machine: x86_64,
clock source: unix,
pcre jit disabled,
detected number of CPU cores: 8,
current working directory: /srv/myapp,
detected binary path: /usr/bin/uwsgi-core,
setgid() to 33,
setuid() to 33,
your memory page size is 4096 bytes,
detected max file descriptor number: 1048576,
lock engine: pthread robust mutexes,
thunder lock: disabled (you can enable it with --thunder-lock),
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.socket fd 3,
your server socket listen backlog is limited to 100 connections,
your mercy for graceful operations on workers is 60 seconds,
mapped 437520 bytes (427 KB) for 5 cores,
*** Operational MODE: preforking ***,
*** no app loaded. going in full dynamic mode ***,
*** uWSGI is running in multiple interpreter mode ***,
!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!,
no request plugin is loaded, you will not be able to manage requests.,
you may need to install the package for your language of choice, or simply load it with --plugin.,
!!!!!!!!!!! END OF WARNING !!!!!!!!!!,
spawned uWSGI master process (pid: 25),
spawned uWSGI worker 1 (pid: 28, cores: 1),
spawned uWSGI worker 2 (pid: 29, cores: 1),
spawned uWSGI worker 3 (pid: 30, cores: 1),
spawned uWSGI worker 4 (pid: 31, cores: 1),
spawned uWSGI worker 5 (pid: 32, cores: 1),
Однако я не вижу ничего плохого в этой очень простой настройке. Моя настройка:
core / __ init __. Py
from flask import Flask
def create_app():
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
return app
app.py
from core import create_app
app = create_app()
if __name__ == '__main__':
app.run()
Dockerfile
FROM python:3.6-slim
RUN apt-get clean \
&& apt-get -y update
RUN apt-get -y install uwsgi nginx
COPY . /srv/myapp
COPY nginx.conf /etc/nginx
WORKDIR /srv/myapp
RUN pip install -r requirements.txt
RUN chmod +r uwsgi.ini
RUN chmod +x ./start.sh
CMD ["./start.sh"]
начало. sh
#!/usr/bin/env bash
service nginx start
uwsgi --ini uwsgi.ini
uwsgi.ini
[uwsgi]
module = app:app
uid = www-data
gid = www-data
master = true
processes = 5
socket = /tmp/uwsgi.socket
chmod-sock = 664
vacuum = true
die-on-term = true
nginx .conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;events
{
worker_connections 1024;
use epoll;
multi_accept on;
}
http {
access_log /dev/stdout;
error_log /dev/stdout;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
index index.html index.htm;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /var/www/html;
location /
{
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi.socket;
}
}
}
Если я добавлю python3 плагин RUN apt-get -y install uwsgi nginx uwsgi-plugin-python3
в DOCKERFILE и запустил uwsgi через uwsgi --ini uwsgi.ini --plugin python3
, я получу:
Traceback (most recent call last):
File "./app.py", line 1, in <module>
from core import create_app
File "./core/__init__.py", line 1, in <module>
from flask import Flask
ModuleNotFoundError: No module named 'flask'
Не знаю, может ли это быть намеком. Любая помощь приветствуется! Спасибо!