首页 > 解决方案 > 让 Firefox 在 Heroku 应用程序上运行:XPCOMGlueLoad 错误

问题描述

我正在尝试让 Firefox 在 Heroku 上运行。我最近的构建成功但有一些问题:

  1. 尝试访问应用程序的 URL 时出现“应用程序错误”(“检查您的日志heroku logs --tail”)。

  2. 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

  3. 上述 H14 错误的典型解决方案是放大测功机:

    ➜ myapp git:(master) ✗ heroku ps:scale web=1
    Scaling dynos... !
    ▸ Couldn't find that process type (web).

  4. 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

到目前为止,我已经尝试了以下构建包,结果没有任何变化:

  1. heroku-集成-firefox-geckodriver
  2. 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

标签: ruby-on-railsselenium-webdriverherokufirefox

解决方案


buitron buildpack 存在一些问题,包括由于缺少分号而导致的长期未修复的错误。

当前的建议是使用evosystem-jp 的 buildpack。我通过克隆 buildpack 并更新到最新版本的 Firefox 和 Geckodriver 来让它工作。


推荐阅读