Hello there!
I’d like to run a small electron script on Heroku. The script simply loads an url (of a local html file) and takes a screenshot of it. Here is a gist with the script main.js
and two html files:
Nothing too fancy. I run it using the electron-prebuilt
package: electron /path/to/script/folder 800x600 file:///path/to/html/file /tmp/sample.png
.
This runs perfectly on my local machine.
Now,the idea is to run it on Heroku. I deployed the electron script using the node.js buildpack. I also needed xvfb
which I installed with these buildpacks and scripts: http://stackoverflow.com/questions/28687120/is-it-possible-to-run-xvfb-on-heroku.
Now, if I connect to bash (heroku run bash
) and try to run the script with:
xvfb-run -s "-ac -screen 0 1000x1000x24" electron /path/to/script/folder 800x600 file:///path/to/html/file /tmp/sample.png
I get the following results:
- for the
sample_text.html
file, it works perfectly. - for the
sample_image.html
file, I get an empty screenshot.
I tried to run this on a vagrant Ubuntu server and it works correctly for the sample_text.html
and sample_image.html
files.
I’m not sure why I’m getting an empty screenshot for the image sample. First, I thought that it would be something to do with xvfb
but it’s working correctly for the text sample.
If anyone has some experience with electron + heroku + xfvb and has some idea of what’s going on, I would be super grateful.