Я запустил приложение для фляжек, которое использует Celery для запуска задач. Для запуска приложения я использую gunicorn с eventlet, и он отлично работает с дистрибутивом Alpine Linux.
Однако мне пришлось перейти на Ubuntu из-за некоторых проблем со sklearn и другими библиотеками, и теперь у меняпроблемы с запуском моего приложения.
Сначала я получаю эту ошибку:
Error: class uri 'eventlet' invalid or not found:
[Traceback (most recent call last):
File "/myapp/env/lib/python3.6/site-packages/gunicorn/workers/geventlet.py", line 11, in <module>
import eventlet
ModuleNotFoundError: No module named 'eventlet'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/myapp/env/lib/python3.6/site-packages/gunicorn/util.py", line 135, in load_class
mod = import_module('.'.join(components))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/myapp/env/lib/python3.6/site-packages/gunicorn/workers/geventlet.py", line 13, in <module>
raise RuntimeError("You need eventlet installed to use this worker.")
RuntimeError: You need eventlet installed to use this worker.
Затем я попытался добавить pip install eventlet
в Dockerfile моего приложения, и теперь у меня есть это другоеошибка:
Error: class uri 'eventlet' invalid or not found:
[Traceback (most recent call last):
File "/myapp/env/lib/python3.6/site-packages/gunicorn/util.py", line 135, in load_class
mod = import_module('.'.join(components))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/myapp/env/lib/python3.6/site-packages/gunicorn/workers/geventlet.py", line 11, in <module>
import eventlet
File "/myapp/env/lib/python3.6/site-packages/eventlet/__init__.py", line 10, in <module>
from eventlet import convenience
File "/myapp/env/lib/python3.6/site-packages/eventlet/convenience.py", line 7, in <module>
from eventlet.green import socket
File "/myapp/env/lib/python3.6/site-packages/eventlet/green/socket.py", line 21, in <module>
from eventlet.support import greendns
File "/myapp/env/lib/python3.6/site-packages/eventlet/support/greendns.py", line 69, in <module>
setattr(dns.rdtypes.IN, pkg, import_patched('dns.rdtypes.IN.' + pkg))
File "/myapp/env/lib/python3.6/site-packages/eventlet/support/greendns.py", line 59, in import_patched
return patcher.import_patched(module_name, **modules)
File "/myapp/env/lib/python3.6/site-packages/eventlet/patcher.py", line 126, in import_patched
*additional_modules + tuple(kw_additional_modules.items()))
File "/myapp/env/lib/python3.6/site-packages/eventlet/patcher.py", line 100, in inject
module = __import__(module_name, {}, {}, module_name.split('.')[:-1])
File "/myapp/env/lib/python3.6/site-packages/dns/rdtypes/IN/WKS.py", line 25, in <module>
_proto_tcp = socket.getprotobyname('tcp')
OSError: protocol not found
Вот так я запускаю свое приложение (start.sh
):
gunicorn -w 1 --worker-class eventlet --certfile=myapp/myapp.crt --keyfile=myapp/myapp.key --bind 0.0.0.0:5000 --log-config myapp/gunicorn.conf myapp.run:app
Все работало нормально, пока я не перешел на Ubuntu на основеконтейнер.
Что мне здесь не хватает?
Я ценю любую помощь.
Спасибо!