Mikael's blog

A developers seventh time trying to maintain a blog

Experimental server is up

I’ve put up a node test server running on port 1337 (it was already forwarded to my server for reasons forgotten by me) and I configured node-static to take care of all my static files.

If you want give it a go, head to http://www.lofjard.se:1337 (EDIT: not available anymore) and have a look at an exact copy of this site running on another web server.

Setting up node-static turned out to be pretty simple. Example stolen from node-static’s GitHub page:

var static = require('node-static');

// Create a node-static server instance to serve the './public' folder
var file = new(static.Server)('./public');

require('http').createServer(function (request, response) {
  request.addListener('end', function () {
    // Serve files!
    file.serve(request, response);

Since this blog is currently all static files there’s not really all that much to my node code but I wanted to get a feel for how it holds up.

I also installed supervisor so that the server gets restarted should it crash.

Supervisor also has the nifty ability to monitor changes to your files so that it can automatically restart node when updates are made to the server code. Very handy in the development phase.

by Mikael Lofjärd
I'm sorry, but comments are not implemented yet.

Sorry, sharing is not available as a feature in your browser.

You can share the link to the page if you want!