Is it possible to run xvfb on Heroku?
Asked Answered
D

3

8

I'd like to run xvfb on Heroku. On my mac, I used the dmg to install it. Would anyone have any idea how to go about this on Heroku?

I came across these buildpacks (http://github.com/douglasjsellers/heroku-xvfb-buildpack) - but following the instructions didn't seem to solve the problem as xvfb is still not installed properly. Also, I tried installing the xvfbwrapper (https://pypi.python.org/pypi/xvfbwrapper/0.1.0), but it's still not working on Heroku (apologies for what is potentially a noob question).

Here is the error I get in my logs off of Heroku:

2015-02-24T02:09:16.035298+00:00 app[web.6]: cmd=['Xvfb', '-help']
2015-02-24T02:09:16.035564+00:00 app[web.6]: Program install error! 
2015-02-24T02:09:16.035302+00:00 app[web.6]: OSError=[Errno 2] No such file or directory

Here is the code:

temp = tempfile.mkstemp(suffix='.html')
html = os.fdopen(temp[0], "r+")
html.write(cv)
html.seek(0, 0)

display = Display(visible=0, size=(800, 600))
display.start()

# Open the file on Selenium to load the JavaScript
driver = webdriver.Firefox()
driver.get("file://" + temp[1])
Diopside answered 24/2, 2015 at 2:15 Comment(1)
I'm stuck too. Yesterday I got it working on amazon quite easily, but it just won't budge on heroku.Anacoluthia
S
7

I found this question while researching how to update Xvfb for Cedar-14, and I managed to get #2 to work. So here's how:

  1. I used buildpack-apt to install x11-xkb-utils xvfb x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic libxfont1 xvfb.

  2. After running the apt buildpack, you need to patch Xvfb a bit to make everything work smoothly. For that, I used my own run-bash buildpack, but everything that lets you run a bash script during Heroku compile will work. Here's the script I used to patch Xvfb and index the fonts: https://gist.github.com/fxtentacle/960cdb96ece01add8686

  3. Now you can use heroku run bash to check with XAUTHORITY=/tmp/xvfb-run.2NG0xl/Xauthority Xvfb ":99" -screen 0 1280x1024x24 -nolisten tcp that the Xvfb is working.

Supplicatory answered 11/12, 2015 at 9:12 Comment(0)
S
4

Yes, it is possible, but complicated. I followed some of what fxtentacle did (in their answer), but this may be simpler. These instructions provide for a minimal Xvfb setup; it still prints out a bunch of warnings.

Use heroku-buildpack-apt to install the xvfb and libnotify4 debian packages. Then use this buildpack to fix the /usr/bin/xkbcomp issue: https://github.com/captain401/heroku-buildpack-xvfb

Then you can use xvfb-run $PROGRAM to run your application.

Silica answered 15/12, 2015 at 23:46 Comment(5)
Using above instruction I was able to run xvfb-run. Unfortunately electron fails with: error while loading shared libraries: libnotify.so.4: cannot open shared object file: No such file or directory. Running it manually via bash didn't give any error. libnotify4 is installed -- under /app/.apt. I wonder why node process didn't pick up LD_LIBRARY_PATH env var.Kt
Ah, this changed sometime in the last month - did you install libnotify4 via the Aptfile for heroku-buildpack-apt? I also had to add it (in addition to xvfb). You can check your LD_LIBRARY_PATH by running heroku run bash to get a shell.Silica
Yeah, I installed via Aptfile. Invoking electron with xvfb-run on bash did not give me any issue. However, doing it via a nodejs process never worked for me :(. I even tried to set LD_LIBRARY_PATH from Heroku config, no luck -- it's libnotify4 issue again.Kt
Electron has other issues too - this is fixed in a very recent release: bugs.chromium.org/p/chromium/issues/detail?id=522853Silica
Has anyone gotten this to work recently? .. I'm pulling my hair out the last two days Xvfb ":99" -screen 0 1280x1024x24 -nolisten tcp _XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root XKB: Failed to compile keymap Keyboard initialization failed. This could be a missing or incorrect setup of xkeyboard-config. (EE) Fatal server error: (EE) Failed to activate virtual core keyboard: 2(EE)Delapaz
V
2

I'm wondering the same thing. Seems like you already found this guy's issue. All the buildpacks mentioned are 1+ years old, and don't work anymore.

Two viable seeming options:

  1. Compile a self-contained xvfb binary a la https://github.com/kenshin23/xvfb-portable-binary that runs on Heroku's current OS and architecture, rebuild when they update.

  2. Install all dependencies from the apt package manager into someplace like ~/.apt, and run from there, as in the latest buildpack-apt. For me, this option dies with sh: 1: /usr/bin/xkbcomp: not found. Xvfb is looking in /, while apt installed the command to ~/.apt/usr/bin/xkbcomp. Haven't figured out how to tell Xvfb to look in ~/.apt/.

Vincennes answered 24/2, 2015 at 4:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.