Skip to content

Instantly share code, notes, and snippets.

@eirikb

eirikb/server.js Secret

Last active December 11, 2015 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eirikb/60f3fb94a334eb7cf63b to your computer and use it in GitHub Desktop.
Save eirikb/60f3fb94a334eb7cf63b to your computer and use it in GitHub Desktop.
var cp = require('child_process');
var path = require('path');
var http = require('http');
var n = cp.fork(path.join(__dirname, 'test.js'));
var port = process.env.PORT || 3000;
http.createServer().listen(port);
n.send('hello');
n.on('message', function(m) {
console.log(m);
});
process.on('message', function(m) {
process.send(m + ', world!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment