forked from alanjoxa/broomify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (31 loc) · 1.05 KB
/
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
35
36
37
var http = require('http');
var request = require('request');
var express = require('express');
var app = express();
var _ = require('underscore');
var path = require('path');
var bodyParser = require('body-parser');
var Pair = require('./service/pair.js');
var ip = require('./service/ip.js');
var routes = require('./routes/index');
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());
routes(app); // attach all routes
process.argv.forEach(function(val, index, array) {
if (val.indexOf('=') !== -1) {
var arg = val.split("=");
process.env[arg[0]] = arg[1];
}
});
var proxyServer = +process.env['-from'] || +process.env['NODE_PORT'] || 8888;
var server = http.createServer(app).listen(proxyServer, function(){
console.log('Proxyserver started at ' + proxyServer);
});
//console.log(server.address());
var config = server.address();
config.address = ip;
console.log(ip);
Pair.setServer(config);