在部署zappa
flask
应用程序 with selenium
、 usingchromedriver
和时遇到了几个问题headless_chromium
。
部署进展顺利,直到最后出现 502 错误。zappa tail
揭示了以下异常:
: WebDriverException
Traceback (most recent call last):
File "/var/task/handler.py", line 580, in lambda_handler
return LambdaHandler.lambda_handler(event, context)
File "/var/task/handler.py", line 245, in lambda_handler
handler = cls()
File "/var/task/handler.py", line 139, in __init__
self.app_module = importlib.import_module(self.settings.APP_MODULE)
File "/var/lang/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 "/tmp/lambda-selenium/src/main.py", line 29, in <module>
driver = webdriver.Chrome('/tmp/lambda-selenium/bin/headless-chromium', chrome_options=chrome_options)
File "/tmp/lambda-selenium/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/tmp/lambda-selenium/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/tmp/lambda-selenium/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /tmp/lambda-selenium/bin/headless-chromium unexpectedly exited. Status code was: 1
据我记得6,当本地遇到此错误时,可以通过安装一些丢失的软件包轻松修复。但 Lambda 是这样吗?如果是,那么我如何在 Lambda 上安装它们?
老实说,我已经用尽了所有可能的想法。我使用这两个指南进行部署: