forked from JacksonTian/ping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.js
executable file
·39 lines (30 loc) · 866 Bytes
/
proxy.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
35
36
37
38
39
var http = require("http");
var cp = require("child_process");
var map = {
"www.nodev5.com": "www",
"assets.nodev5.com": "assets"
};
var fork = function () {
var worker = cp.fork.apply(cp, arguments);
worker.on('message', function (message) {
});
return worker;
};
var workers = {
www: cp.fork(__dirname + "/asset_app.js", [8001]),
assets: cp.fork(__dirname + "/v5_app.js", [8002]),
};
var server = http.createServer(function(request, response) {
// TODO
switch()
var worker = workers[map[request.headers.host]] || workers["assets"];
//worker.send("", server._handle);
// console.log(server);
// response.writeHead(200);
// response.end();
});
server.on("connection", function (socket) {
console.log(socket);
});
server.listen(8080);
console.log("Server runing at port: 80.");