Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running electron (atom-shell) headlessly on linux server through Nightmare.js

I am building a scraper to make JS single page applications easily crawlable.

After some incredible frustration with PhantomJS (memory leaks, outdated webkit, undead processes, among many other problems) I decided to switch to NightmareJS which can do the same things but uses Electron under the hood. Electron has a lot of advantages (uses latest chromium, is a lot faster) but it needs an X server to run.

As I need to make it work under ubuntu server, I followed this gist . Now I have a great EC2 instance with everything ready to run an headless electron

xvfb-run electron

The point is that I need to run this through nightmareJS (which I will use in a node.js server script). I was wondering how I could pass parameters to nightmare in order to start electron through svfb

like image 965
Rayjax Avatar asked Sep 16 '15 15:09

Rayjax


People also ask

Is Nightmare JS headless Web browser?

Nightmare is a browser automation library. It's a solid choice for automating smoke tests to do all of the clicks, text inputs, and visual checking that a human can do. Under the hood, it uses Electron as a headless browser.

What is Nightmare js?

js is a high-level browser automation library, designed to automate browsing tasks for sites that don't have APIs. The library itself is a wrapper around Electron, which Nightmare. js uses as a browser to interact with web sites.


1 Answers

I don't know if there is a better way, but at least for my works run the main process using xvfb-run command:

$ xvfb-run node --harmony simple-service.js
Worker 12153 is online
Worker 12155 is online
Worker 12154 is online
Worker 12156 is online
like image 100
Marco Salgado Avatar answered Oct 16 '22 20:10

Marco Salgado