File tree Expand file tree Collapse file tree 5 files changed +43
-20
lines changed
Expand file tree Collapse file tree 5 files changed +43
-20
lines changed Original file line number Diff line number Diff line change @@ -4,5 +4,6 @@ exports.install = function(framework) {
44
55function view_homepage ( ) {
66 var self = this ;
7+ process . send ( 'Response framework ID: ' + self . framework . id ) ;
78 self . view ( 'homepage' ) ;
89}
Original file line number Diff line number Diff line change 1+ var http = require ( 'http' ) ;
2+ var cluster = require ( 'cluster' ) ;
3+ var os = require ( 'os' ) ;
4+
5+ var debug = true ;
6+
7+ if ( ! cluster . isMaster ) {
8+
9+ // This code will be executed according the number of CPU
10+ // This code will be using: single process RAM * numCPUs
11+ var framework = require ( 'total.js' ) ;
12+
13+ // Set framework ID
14+ framework . on ( 'message' , function ( message ) {
15+ if ( message . type === 'id' )
16+ framework . id = message . id ;
17+ } ) ;
18+
19+ framework . run ( http , debug ) ;
20+ console . log ( "http://{0}:{1}/" . format ( framework . ip , framework . port ) ) ;
21+ return ;
22+ }
23+
24+ var numCPUs = os . cpus ( ) . length ;
25+
26+ for ( var i = 0 ; i < numCPUs ; i ++ ) {
27+
28+ // Run framework
29+ var fork = cluster . fork ( ) ;
30+
31+ fork . on ( 'message' , onMessage ) ;
32+
33+ // Send ID
34+ fork . send ( { type : 'id' , id : i } ) ;
35+ }
36+
37+ function onMessage ( message ) {
38+ console . log ( 'Message ->' , message ) ;
39+ }
40+
41+ // Use a terminal for testing:
42+ // $ siege -b -r 10 http://127.0.0.1:8004/
File renamed without changes.
File renamed without changes.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments