Created
January 27, 2016 05:48
-
-
Save alber999/c8169e2aa6394c58945e to your computer and use it in GitHub Desktop.
Sample of NodeJS as a cluster + Express + Hogan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Cluster NodeJS + Express + Hogan | |
* | |
* "dependencies": { | |
* "express": "~4.13.3", | |
* "hogan-middleware": "*" | |
* } | |
*/ | |
var cluster = require('cluster'); | |
if (cluster.isMaster) { | |
var cpuCount = require('os').cpus().length; | |
for (var i = 0; i < cpuCount; i += 1) { | |
cluster.fork(); | |
} | |
} else { | |
var express = require('express'); | |
var app = express(); | |
app.set('view engine', 'mustache'); | |
app.engine('mustache', require('hogan-middleware').__express); | |
app.get('/', function (req, res) { | |
res.render('index',{msg:'Hello world!'}) | |
}); | |
app.listen(3000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment