This file contains hidden or 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
| var cluster = require("cluster"); | |
| cluster.restart = function (callback) { | |
| var oldWorkers = []; | |
| cluster.eachWorker(function (worker) { | |
| oldWorkers.push(worker); | |
| }); | |
| function restartWorker (oldWorker) { |
This file contains hidden or 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
| hallo |
This file contains hidden or 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
| for (var i = 0; i < l; i++) { | |
| (function (i) { | |
| http.request(options, function () { | |
| /* use i */ | |
| }); | |
| })(i); | |
| } |
This file contains hidden or 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
| /** | |
| * Copyright (c) 2011 Andreas Madsen | |
| * GPL License Version 3 | |
| */ | |
| html, body, ul, figure, img { | |
| margin: 0; | |
| padding: 0; | |
| font-family: sans-serif; | |
| } |
This file contains hidden or 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
| $ node ./test.js | |
| test: 262ms | |
| GOT: 10240 KB | |
| use pipe: no | |
| $ node ./test.js | |
| test: 248ms | |
| GOT: 10240 KB | |
| use pipe: no | |
| $ node ./test.js | |
| test: 257ms |
This file contains hidden or 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
| var net = require('net'); | |
| var path = require('path'); | |
| var server = net.createServer(); | |
| server.on('connect', function () { | |
| console.log('got request'); | |
| }); | |
| server.on('error', function (err) { |
This file contains hidden or 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
| $ node test | |
| create: 678ms | |
| send: 4445ms | |
| 200 ms passed, or not :/ | |
| got message: 5 MB | |
| get: 4472ms |
This file contains hidden or 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
| var fork = require('child_process').fork; | |
| if (process.argv[2] === 'child') { | |
| setInterval(function () { | |
| console.log('alive ... '); | |
| }, 200); | |
| setTimeout(function () { | |
| console.log('exit child'); | |
| process.exit(0); |
This file contains hidden or 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
| > node test.js | |
| worker ID:1 got message. message-1 | |
| worker ID:0 got message. message-1 | |
| worker ID:1 got message. message-2 | |
| worker ID:0 got message. message-2 |
This file contains hidden or 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
| var child_process = require('child_process'); | |
| function startDeamon(child, args) { | |
| var newEnv = JSON.parse(JSON.stringify(process.env)); | |
| newEnv.deamonOptions = JSON.stringify({exec: child, args: args}); | |
| var deamonWatcher = child_process.fork(process.argv[1], ['deamon'], { |