-
Notifications
You must be signed in to change notification settings - Fork 82
/
server.js
60 lines (37 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var express = require('express')
,app = express()
,bunyan = require('bunyan')
,_ = require('underscore')
,util = require('util')
,os = require('os')
,sys = require('sys')
,exec = require('child_process').exec;
var rootDir = __dirname;
var port = 3000;
app.use(express.json());
app.use(express.urlencoded());
app.use(express.static(rootDir));
app.all('/app/',function(req,res){
console.log(new Date());
exec("gulp test",puts);
res.send('ok');
})
app.listen(port);
//===================
console.log()
console.log('Current Directory: '+__dirname)
console.log('Serving files from: '+rootDir)
console.log('Listening on: ' + getAddresses() + ':' + port + '');
console.log('Press Ctrl + C to stop.');
//=====================
function getAddresses(){
var interfaces = os.networkInterfaces(),
addresses = [];
_.each(interfaces,function(net){
_.each(net,function(address){
if (address.family == 'IPv4' && !address.internal) addresses.push(address.address);
})
})
return addresses;
}
function puts(error, stdout, stderr) {sys.puts(stdout)}