Skip to content

Instantly share code, notes, and snippets.

@carstenschwede
Forked from nf/hello-node.js
Created April 16, 2014 10:24
Show Gist options
  • Save carstenschwede/10848473 to your computer and use it in GitHub Desktop.
Save carstenschwede/10848473 to your computer and use it in GitHub Desktop.
var cluster = require('cluster');
if (cluster.isMaster) {
return require('os').cpus().forEach(cluster.fork);
}
require('http').createServer(function(req, res) {
res.end("hello world\n");
}).listen(8000);
package main
import (
"net/http"
"runtime"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
handler := func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello world\n"))
}
http.ListenAndServe(":8000", http.HandlerFunc(handler))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment