-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
59 lines (48 loc) · 1.84 KB
/
server.js
File metadata and controls
59 lines (48 loc) · 1.84 KB
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
58
59
var express = require('express'),
app = express(),
routes = require('./lib/routes'),
sockets = require('./lib/sockets'),
server = require('http').createServer(app),
io = require('socket.io').listen(server);
var isProduction = (process.env.NODE_ENV === 'production');
var port = (isProduction ? 80 : 8000);
require('nko')('OsOQBZoKPwLCYTav');
app.use(express.static(__dirname + '/static'));
app.engine('html', require('ejs').renderFile);
app.set('views', __dirname + '/views');
routes.init(app);
sockets.init(io);
server.listen(port, function(e) {
if(e) {
console.error(e);
process.exit(-1);
}
// RL - don't know whether we need this - leave it in for now
// if run as root, downgrade to the owner of this file
if (process.getuid() === 0) {
require('fs').stat(__filename, function(err, stats) {
if (err) { return console.error(err); }
process.setuid(stats.uid);
});
}
console.log('Server running at http://0.0.0.0:' + port + '/');
} );
// https://github.com/nko4/website/blob/master/module/README.md#nodejs-knockout-deploy-check-ins
/*
http.createServer(function (req, res) {
// http://blog.nodeknockout.com/post/35364532732/protip-add-the-vote-ko-badge-to-your-app
var voteko = '<iframe src="http://nodeknockout.com/iframe/0x" frameborder=0 scrolling=no allowtransparency=true width=115 height=25></iframe>';
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<html><body>' + voteko + '</body></html>\n');
}).listen(port, function(err) {
if (err) { console.error(err); process.exit(-1); }
// if run as root, downgrade to the owner of this file
if (process.getuid() === 0) {
require('fs').stat(__filename, function(err, stats) {
if (err) { return console.error(err); }
process.setuid(stats.uid);
});
}
console.log('Server running at http://0.0.0.0:' + port + '/');
});
*/