Pure headless on Linux

382 views
Skip to first unread message

Ariya Hidayat

unread,
Mar 13, 2012, 10:55:54 PM3/13/12
to phan...@googlegroups.com
Folks,

The clock is ticking, but here is some news about getting PhantomJS to
be fully X11-less.

For the setup, I use Ubuntu Lucid installed to a small virtual
machine. I pick the rather outdated Lucid in the hope that if it works
there, it would work on a more modern flavor. The installation is
server oriented, there is no GUI so it's all the fancy text mode.
Packages pulled after the fresh installation are only:

sudo apt-get install build-essential chrpath git-core libssl-dev
libfontconfig1-dev

So far I manage to get various examples working, even rendering the
SVG version of the famous Tiger to PNG! For simplicity, I also let the
minimal Lighthouse implementation baked in rather than making it as a
plugin (I still have a remote hope that static build on Linux would be
possible in the near future). Text is rendered via Freetype2 and
Fontconfig which is nice since we will still get high quality
rendering even on an environment sans GUI.

The attached screenshot shows how I use PhantomJS to render the Tiger
into a PNG and also use another PhantomJS script again to upload the
resulting image (since there is no GUI browser).

The theory is that if this works on a barebone Lucid server, then
we're heading in the right direction :)


Thanks!

Regards,


--
Ariya Hidayat, http://ariya.ofilabs.com

rendertiger.png

Vijay Boyapati

unread,
Mar 14, 2012, 1:44:02 AM3/14/12
to phan...@googlegroups.com
This is so awesome! Thanks for all your hard work Ariya. I can't wait to use this

Mike Alaimo

unread,
Mar 14, 2012, 9:32:22 AM3/14/12
to phan...@googlegroups.com

Indeed, Phantomjs is a work of art.  I hope to utilize the pure headless feature very soon.

Brian Donovan

unread,
Mar 14, 2012, 10:54:14 AM3/14/12
to phantomjs
Awesome! I'm happy to help test this on OS X, which is where I
primarily use phantomjs.
>  rendertiger.png
> 240KViewDownload

Ariya Hidayat

unread,
Mar 14, 2012, 11:10:43 AM3/14/12
to phan...@googlegroups.com
> This is so awesome! Thanks for all your hard work Ariya. I can't wait to use
> this

I've pushed the stuff to master branch so if you feel brave, you can
try it now already.

I think JPEG support is broken in the middle of the process, I'm
trying to find the problem.


Best regards,

Ariya Hidayat

unread,
Mar 14, 2012, 11:12:27 AM3/14/12
to phan...@googlegroups.com
> Awesome! I'm happy to help test this on OS X, which is where I
> primarily use phantomjs.

Hi Brian, I believe in the mean time we keep this pure headless
feature on Linux only (for reasons I'll write later on).

Any specific scenarios why you need this on OS X?

Ariya Hidayat

unread,
Mar 14, 2012, 1:00:23 PM3/14/12
to phan...@googlegroups.com
To add some more excitement, remote debugging works like a charm!

The following scenario is now possible:

* Remote login to your Linux box (could be anywhere in the world)
* Invoke PhantomJS script with remote debugger option
* Open Chrome/Safari and point to the box's IP address + debugger port
* Single-step, watch, breakpoint your script just like in standard's
Web Inspector UI
* Profit!

I know that remote debugging feature is still alien to many people.
Don't worry, there will be a whole wiki page for that soon!

Fun times ahead :)

Brian Donovan

unread,
Mar 15, 2012, 12:44:44 PM3/15/12
to phan...@googlegroups.com
I use phantomjs with guard-jasmine to run JS specs as I work on my projects. The only negative part of the setup is that starting phantomjs doesn't play nice with Lion full-screen apps (if you're in a full-screen app when it starts then you'll be pushed to a "desktop" window). It's not a huge deal and can be worked around (it typically happens while editing, and I use vim+iTerm, so I just have to use non-Lion style full-screen in iTerm and set it up as a separate desktop), but it'd be nice for the process not to be visible in cmd+tab/dock.

-bd

Ariya Hidayat

unread,
Mar 15, 2012, 9:22:45 PM3/15/12
to phan...@googlegroups.com
> I use phantomjs with guard-jasmine to run JS specs as I work on my projects.
> The only negative part of the setup is that starting phantomjs doesn't play
> nice with Lion full-screen apps (if you're in a full-screen app when it
> starts then you'll be pushed to a "desktop" window).

Does the PhantomJS icon show up in the Dock? If that is the case, it
is already fixed, see
http://code.google.com/p/phantomjs/issues/detail?id=281.

Ariya Hidayat

unread,
Mar 15, 2012, 11:19:44 PM3/15/12
to phan...@googlegroups.com
> I think JPEG support is broken in the middle of the process, I'm
> trying to find the problem.

JPEG support has been restored.

witwall

unread,
Mar 17, 2012, 5:18:39 AM3/17/12
to phan...@googlegroups.com
Recommend PHantomJS integrate with the great feather of wkhtmltopdf
http://code.google.com/p/wkhtmltopdf/
Real headless
Great PDF output
Output as a dynamic library
Reply all
Reply to author
Forward
0 new messages