-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathserver.js
34 lines (24 loc) · 803 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Module dependencies.
*/
//this is only for joyent.
var express = require('express')
, app = module.exports = express.createServer();
app.get("/",function(req,res) {
res.redirect("http://chessathome.org/");
});
var ENGINE_PATH = './build/engine.js'
, socketio = require('socket.io-client')
, path = require('path')
, Worker = require('webworker').Worker
, startWorker = require("./worker/worker.js").startWorker;
//TODO CLI switches
var CLI_PROCESSES = 2;
var VERBOSE = false;
if (require.main === module) {
for (var i=0;i<CLI_PROCESSES;i++) {
startWorker({host: process.ARGV[2] || 'chessathome.org', port: process.ARGV[3] || 80}, 'joyent-' + i,path.resolve(__dirname, ENGINE_PATH), socketio, Worker, VERBOSE);
}
}
//TODO stop ?
app.listen(process.env.PORT || 3001);