FWeinb / electron-screenshot-service

Take screenshots using electron
MIT License
141 stars 26 forks source link

Doesn't throw an error and it just hangs on Ubuntu 16.04 with NodeJS 6.10.3 #37

Open Defrothew opened 7 years ago

Defrothew commented 7 years ago

First of all, thanks for this useful package.

I have server on DigitalOcean with this following setup: Ubuntu 16.04 NodeJS 6.10.3

Used the code below:

var fs = require('fs'); var screenshot = require('electron-screenshot-service');

screenshot({ url : 'http://google.de', width : 1024, height : 768 }) .then(function(img){ fs.writeFile('./out.png', img.data, function(err){ screenshot.close(); }); });

Unfortunately, when I run this code, it just hangs and doesn't display any errors in the console nor in the debug file for node.js.

PlanetIrata commented 7 years ago

Same here with Debian Jessie (v8.8) and Node v8.1.2, the same code that works under Windows 10 / Node v8 hangs under Debian without throwing any error.

Thanks for help

taboca commented 7 years ago

Same here, just got a new Digital Ocean machine with Ubuntu as pointed above and stalls.

kribblo commented 7 years ago

I had this problem trying to run this in a headless container, guess it's the same for you guys; electron needs a DISPLAY to render to, so you need to use something like Xvfb and probably some extra GUI dependencies if it's Ubuntu server edition.

Didn't take the time to figure out exactly what is needed, but in my Dockerfile I have these lines that makes it run for me:

RUN apt-get update && apt-get install -yq xvfb libgtk2.0-0 libgconf2-4 libnss3 libasound2 libxtst6 xvfb gtk2-engines-pixbuf libnotify-dev dbus-x11 libxss1
ENV DISPLAY :99
CMD xvfb-run --server-args='-screen 0 1024x768x24 -ac +extension RANDR' npm start

:99 is default DISPLAY for xvfb-run; there's multiple other ways to run this, and you may not use Docker at all, but in short:

Hope that helps.