Recently I had to reinitialize my webserver, doing some updates and just clean up all the stuff, with that I broke with testing the previous installation. For the new system I decided, that it should be hosted with nodejs, not with apache. Doing that step, I also had to move from wordpress to something new. The server I had already running several nodejs services. That help me to watch youtube videos in china or store files right from the web.

Now the main webserver should be replaced. After checking some options, I decided to run the node process on a port of my choice and redirect port 80 to that new port using iptables. In this way, the node process don’t need to get started with root-privileges. With my previous nodejs services I had the problem, that they always shut down over time. The solution for that is as the following listing:

process.on('uncaughtException', (err)=>{
console.log(err); // actually I log into a file

This snipped prevent the server from shutdown after an error and later I can check out what happened. So the issue was, that the servers logged to console. The console was filled up. and the process broke. This issue was the same with using forever, pm2 or run the server in background and ‘disown’.

The server that is running now is an express server, serving static files from its public directory. First I begun to do prepare some basic layout writing underscore templates, managed by my template manager. But actually I didn’t wanted to build a layout now. That made me looking for static page generators. On github are many pages made using jekyll. But it is a system made with Ruby and I wanted to use something with node.

After a while, crawling some websites, I found Hexo. A static page generator, that has some CLI program to initialize a new project, import content from my wordpress page, create new pages and posts. The structure with pages and posts has directly been familiar to me. For Hexo, there are about 50 themes on the official website. I chose one and tweaked it to look like a page for a software developer. The theme is already responsive and looks very clean.

I can directly write new posts and pages from the console. The cli initializes for each a new markdown file. Where I can directly write new content. For local, to check out how the page looks the cli-tools provides a build-in webserver, that will live regenerate the page. For production, you use “hexo generate” to create the static html-files. after generating simple copy the files to the public directory of my live host and there is the new content. The system even generates archive pages that let the visitor brows the site by time. on the sidebar is a tag-cloud, that help to explore the web-side with given tags. This will be a great plus for Search Engine Optimization.

For now I am very excited about hexo, it is great to make simple websites and I can have a good separation from the rest of the code, that I will add to the server.