Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'origin/master' into eleveldb-logging

Conflicts:
	competition/wsdemo-ws.js
  • Loading branch information...
commit 3f65f66b1f587edf557a39ee7dfab1cf53bf73e1 2 parents ed5b504 + 1be37eb
@ericmoritz ericmoritz authored
Showing with 25 additions and 9 deletions.
  1. +22 −7 competition/wsdemo-ws.js
  2. +3 −2 configure_ubuntu.sh
View
29 competition/wsdemo-ws.js
@@ -1,10 +1,25 @@
#!/usr/bin/env node
-var ws = require('ws')
-, wss = new ws.Server({port:8000, host:"0.0.0.0"})
+var http = require('http')
+ , cluster = require('cluster')
+ , numCPUs = require('os').cpus().length
-wss.on('connection', function(con) {
-
- con.on('message', con.send)
-
-})
+if (cluster.isMaster) {
+ // Master Process
+ var versionInfo = process.version.substr(1).split('.').map(function(v) { return parseInt(v); });
+ if (versionInfo[1] !== 7 || versionInfo[2] < 11) {
+ console.error('Please use node v0.7.11+\nAfter installing v0.7, please run "npm rebuild ws".');
+ process.exit(-1);
+ }
+ for (var i = 0; i < numCPUs; i++) cluster.fork();
+}
+else {
+ // Worker Process
+ var ws = require('ws')
+ , server = http.createServer()
+ , wss = new ws.Server({server: server});
+ server.listen(8000, 3000); // increased socket backlog
+ wss.on('connection', function(con) {
+ con.on('message', con.send);
+ });
+}
View
5 configure_ubuntu.sh
@@ -8,13 +8,14 @@ sudo sysctl -p
mkdir src
pushd src
- curl http://nodejs.org/dist/v0.6.19/node-v0.6.19.tar.gz | tar xz
- pushd node-v0.6.19
+ curl http://nodejs.org/dist/v0.7.11/node-v0.7.11.tar.gz | tar xz
+ pushd node-v0.7.11
./configure && make && sudo make install
popd
popd
npm install websocket
+npm install ws
sudo go get code.google.com/p/go.net/websocket
sudo gem install em-websocket
Please sign in to comment.
Something went wrong with that request. Please try again.