Skip to content

Commit

Permalink
throng and native clustering tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fcirone committed Jul 20, 2016
1 parent 1a6d684 commit bdf7f2f
Show file tree
Hide file tree
Showing 318 changed files with 48,983 additions and 2 deletions.
68 changes: 68 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#################
## WebStorm
#################

.idea/*

#################
## Visual Studio
#################
*.sln
supplyCONNECT.v12.suo
furry-octo-ironman.njsproj
furry-octo-ironman.sln
furry-octo-ironman.v12.suo
.vscode/*

#################
## Mac
#################
.DS_Store


############
## Windows
############

# Windows image file caches
Thumbs.db

# Folder config file
Desktop.ini

############
## Node
############

node_modules/
npm-debug.log

############
## Configuration
############
config/development.js
config/production.js
config/runtime.json

############
## Misc
############
test/out/
logs/*.log
*.pst
/test/selenium
doc/
content/locales/en_US.json
compile.bat
.ntvs_analysis.dat
tmp/template.html
gitReset.bat
mockCB.bat
importDemand.bat
demandmocker.js
demandMocks.json
projectFilesBackup/
content/shared/public/monkeynaut/
.vscode
content/shared/public/css/*.css
/test/coverage
59 changes: 59 additions & 0 deletions index-throng.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* jshint node: true */
'use strict';

const throng = require('throng');

var WORKERS = process.env.WEB_CONCURRENCY || 1;
var PORT = process.env.PORT || 8001;

// throng({
// workers: WORKERS,
// lifetime: Infinity,
// start: startApp
// });

throng(start);

function start() {
console.log('started');
}

function startApp() {
var express = require('express');
var crypto = require('crypto');
var app = express();

app.listen(PORT, onListen);
// app
// .get('/cpu', cpuBound)
// .get('/memory', memoryBound)
// .get('/io', ioBound)
// .listen(PORT, onListen);

// function cpuBound(req, res, next) {
// var key = Math.random() < 0.5 ? 'ninjaturtles' : 'powerrangers';
// var hmac = crypto.createHmac('sha512WithRSAEncryption', key);
// var date = Date.now() + '';
// hmac.setEncoding('base64');
// hmac.end(date, function() {
// res.send('A hashed date for you! ' + hmac.read());
// });
// }
//
// function memoryBound(req, res, next) {
// var hundredk = new Array(100 * 1024).join('X');
// setTimeout(function sendResponse() {
// res.send('Large response: ' + hundredk);
// }, 20).unref();
// }
//
// function ioBound(req, res, next) {
// setTimeout(function SimulateDb() {
// res.send('Got response from fake db!');
// }, 300).unref();
// }

function onListen() {
console.log('Listening on', PORT);
}
}
35 changes: 35 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var express = require('express');
var cluster = require('cluster');
var os = require('os');//no need to download anything

var PORT = process.env.PORT || 8001;

if(cluster.isMaster) {
var numWorkers = os.cpus().length;
console.log('Master cluster setting up ' + numWorkers + ' workers...');

for(var i = 0; i < numWorkers; i++) {
cluster.fork();
}

cluster.on('online', function(worker) {
console.log('Worker ' + worker.process.pid + ' is online');
});

cluster.on('exit', function(worker, code, signal) {
console.log('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal);
console.log('Starting a new worker');
cluster.fork();
});
} else {
var app = require('express')();

app.listen(PORT, function() {
console.log('Express server listening on %d, in %s mode', PORT, app.get('env'));
});

// // Start server
// server.listen(config.port, config.ip, function () {
// console.log('Express server listening on %d, in %s mode', config.port, app.get('env'));
// });
}
1 change: 1 addition & 0 deletions node_modules/blitzkrieg/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions node_modules/blitzkrieg/blitzkrieg.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions node_modules/blitzkrieg/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/blitzkrieg/readme.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions node_modules/blitzkrieg/test/blitzkrieg.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added node_modules/crypto/.md5.js.un~
Binary file not shown.
Binary file added node_modules/crypto/.package.json.un~
Binary file not shown.
Binary file added node_modules/crypto/.sha1.js.un~
Binary file not shown.
5 changes: 5 additions & 0 deletions node_modules/crypto/History.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions node_modules/crypto/Readme.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bdf7f2f

Please sign in to comment.