ruby-on-rails - 让 Firefox 在 Heroku 应用程序上运行:XPCOMGlueLoad 错误
问题描述
我正在尝试让 Firefox 在 Heroku 上运行。我最近的构建成功但有一些问题:
尝试访问应用程序的 URL 时出现“应用程序错误”(“检查您的日志
heroku logs --tail
”)。heroku logs --tail
错误:2021-05-07T02:37:38.937508+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=www.mysite.com request_id=be150e6e-295d-4121-a90a-gh8519sa174 fwd="<ipaddress>" dyno= connect= service= status=503 bytes= protocol=http
2021-05-07T02:37:39.405719+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=www.mysite.com request_id=6caff434-1hfa-4gqb-a3c3-7209sh2k0cf9 fwd="<ipaddress>" dyno= connect= service= status=503 bytes= protocol=http
上述 H14 错误的典型解决方案是放大测功机:
➜ myapp git:(master) ✗ heroku ps:scale web=1
Scaling dynos... !
▸ Couldn't find that process type (web).
heroku console
错误:XPCOMGlueLoad error for file /app/vendor/firefox/libmozgtk.so:
libgtk-3.so.0: cannot open shared object file: No such file or directory.
Couldn't load XPCOM.
heroku 推送看起来像:
➜ myapp git:(master) ✗ git push heroku master
Enumerating objects: 2, done.
Counting objects: 100% (2/2), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 349 bytes | 349.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: http://github.com/buitron/firefox-buildpack
remote: -----> firefox app detected
remote: -----> Extracting Firefox binaries to /tmp/build_1f06c3e2/vendor/firefox
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote: Default types for buildpack -> console
remote:
remote: -----> Compressing...
remote: Done: 81.7M
remote: -----> Launching...
remote: Released v21
remote: https://myapp.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/myapp.git
到目前为止,我已经尝试了以下构建包,结果没有任何变化:
- heroku-集成-firefox-geckodriver
- buitron 的 firefox-buildpack
我的应用程序只需要在一个地方使用此代码。这是该代码:
require 'webdrivers/geckodriver'
require 'selenium-webdriver'
require 'fileutils'
Selenium::WebDriver.logger.level = :info
# SET UP SELENIUM
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.folderList'] = 2
profile['browser.download.dir'] = download_dir
profile['browser.helperApps.neverAsk.saveToDisk'] = ('application/pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/csv')
options = Selenium::WebDriver::Firefox::Options.new(profile: profile, args: ['-headless'])
driver = Selenium::WebDriver.for :firefox, options: options
driver.manage.timeouts.implicit_wait = 10 # seconds
wait = Selenium::WebDriver::Wait.new(:timeout => 15)
driver.get "https://theurl.com"
...traverse website...
driver.quit
解决方案
buitron buildpack 存在一些问题,包括由于缺少分号而导致的长期未修复的错误。
当前的建议是使用evosystem-jp 的 buildpack。我通过克隆 buildpack 并更新到最新版本的 Firefox 和 Geckodriver 来让它工作。
推荐阅读
- javascript - 如何在 React 中将 ArrayBuffer(PNG 图像)直接渲染为图像?
- python - 通过 xpath 查找 selenium 的元素
- swift - Xcode 自动生成的单元测试
- go - 如何为热图生成 1024 个十六进制颜色值的列表
- c# - 可以在域服务中引发域事件吗?
- c# - PayPal 账单协议 - 无效的计划 ID .NET
- ios - 执行 XCUITest 时,Tap 方法在今日视图中不起作用
- metadata - Google IoT 核心设备元数据
- azure - 在 Azure Web App for Containers 上运行 Rasa bot
- mysql - 有人可以帮助将此 MySql 查询转换为 JPQL 或 HQL 吗?