node-server-screenshot icon indicating copy to clipboard operation
node-server-screenshot copied to clipboard

Will this work on a headless server?

Open whitwhoa opened this issue 6 years ago • 1 comments

While testing this on a windows machine I noticed that an electron window pops up and a screenshot is taken. I changed the width/height options to a resolution larger than my monitor and the screenshot was restricted to the size of my monitor...which leads me to believe that this package is reliant on a windowing system that can draw an electron instance...meaning It would not work for the intended purpose on a headless dedicated server. Is that correct? Or am I mistaken (hoping I'm mistaken because if so this is perfect for what I'm looking to accomplish)?

whitwhoa avatar Jul 19 '19 16:07 whitwhoa

Hi @whitwhoa

This package uses segmentio/nightmare, which in term uses electron (chromium) which has a headless option since version 57.

There is an undocumented option (my bad...) which toggles the window. It's options.show: boolean and by default is true https://github.com/legraphista/node-server-screenshot/blob/41d672b731c1b073079a6873da415c8f6f39c0b0/index.js#L79 https://github.com/legraphista/node-server-screenshot/blob/41d672b731c1b073079a6873da415c8f6f39c0b0/index.js#L143

If you still have an issue running it headless (on linux), consider using xvfb or xvfb-run (example) to make a pseudo-display environment for your script to run into.

legraphista avatar Jul 24 '19 11:07 legraphista