Я развертываю приложение фляги, которое использует cairosvg
, которое используется для преобразования SVG в PDF.Локально приложение работает без сбоев при развертывании на GCP, оно не развертывается и не получает следующую ошибку:
Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
[2018-05-22 18:09:41 +0000] [1] [INFO] Starting gunicorn 19.8.1
[2018-05-22 18:09:41 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[2018-05-22 18:09:41 +0000] [1] [INFO] Using worker: sync
[2018-05-22 18:09:41 +0000] [7] [INFO] Booting worker with pid: 7
[2018-05-22 18:09:42 +0000] [7] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/env/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/env/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/env/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/env/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/env/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
File "/home/vmagent/app/run.py", line 4, in <module>
from api.controllers import (
File "/home/vmagent/app/api/controllers/generateBadges.py", line 7, in <module>
from api.utils.merge_badges import MergeBadges
File "/home/vmagent/app/api/utils/merge_badges.py", line 4, in <module>
from cairosvg import svg2pdf
File "/env/lib/python3.6/site-packages/cairosvg/__init__.py", line 29, in <module>
from . import surface
File "/env/lib/python3.6/site-packages/cairosvg/surface.py", line 24, in <module>
import cairocffi as cairo
File "/env/lib/python3.6/site-packages/cairocffi/__init__.py", line 41, in <module>
cairo = dlopen(ffi, 'cairo', 'cairo-2')
File "/env/lib/python3.6/site-packages/cairocffi/__init__.py", line 38, in dlopen
raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2
[2018-05-22 18:09:42 +0000] [7] [INFO] Worker exiting (pid: 7)
[2018-05-22 18:09:42 +0000] [1] [INFO] Shutting down: Master
[2018-05-22 18:09:42 +0000] [1] [INFO] Reason: Worker failed to boot.
При поиске в Google я обнаружил, что dlopen () не удалось загрузить библиотеку: cairo /cairo-2 но я не знаю, как включить в app.yml
.
мой app.yml
файл:
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app
runtime_config:
python_version: 3
env_variables:
SQLALCHEMY_DATABASE_URI: >-
postgresql+psycopg2://USER:PASSWORD@/DATABASE?host=/cloudsql/INSTANCE_CONNECTION_NAME
beta_settings:
cloud_sql_instances: INSTANCE_CONNECTION_NAME