panel.jpg Follow us on Twitter and Facebook

/// Blog

October 3, 2013
Category: Development Written by: Tagged: node-webkit xvfb

Run node-webkit on a headless Ubuntu EC2 instance

For a latest project, I needed to run node-webkit on an EC2 ubuntu instance. Since, I do not have a display, I needed to create a virtual display as follows.

Install essential packages for XVFB

Let’s install the required packages. The fonts aren’t really necessary but installing them prevents you from getting annoying warnings. xvfb can start a virtual X window on a server where Selenium can start the browser in to run your tests.

sudo apt-get update && sudo apt-get install -y xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic xvfb x11-apps imagemagick

Create script for starting XVFB

To start xvfb I like to have a little start/stop script like this one:

if [ -z "$1" ]; then
  echo "`basename $0` {start|stop}"

case "$1" in
  /usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 &
  killall Xvfb

This will start a Window on display :99. This is important later on. Place the script in /etc/init.d/. To start it automatically on boot, run: sudo update-rc.d xvfb defaults.

Start and stop XVFB

First lets start xvfb sudo /etc/init.d/xvfb start

Now we have to set the DISPLAY env variable so Firefox and Chrome know where to open the browser. export DISPLAY=:99

Now, your node-webkit app should run without any problem using the virtual X window!

PS: Many thanks to the author of the post called Installing Selenium with Jenkins on Ubuntu - LexTech

/// Our Twitter Feed

Find out what's happening, right now, with the people and organizations you care about.

Copyright 2012