-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
61 lines (54 loc) · 1.65 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
58
59
60
61
if(process.env.NODETIME_ACCOUNT_KEY) {
require('nodetime').profile({
accountKey: process.env.NODETIME_ACCOUNT_KEY,
appName: 'gl82'
});
}
var application_root = __dirname,
express = require("express"),
jade = require('jade'),
http = require('http');
var app = express();
// Configure server
app.configure(function() {
app.set('views', __dirname + '/site/views');
app.set('view engine', 'jade');
app.use(express.static(__dirname + '/site'));
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.session({ secret: 'keyboard cat' }));
app.locals.pretty = true;
// app.use(express.logger());
app.use(express.methodOverride());
app.use(app.router);
//Show all errors in development
// app.use(express.errorHandler({dumpExceptions: true, showStack: true}));
});
// Setup routes
require("./routes")(app);
function startKeepAlive() {
setInterval(function() {
var options = {
host: 'gl82.herokuapp.com',
port: 80,
path: '/'
};
http.get(options, function(res) {
res.on('data', function(chunk) {
try {
// optional logging... disable after it's working
// console.log("HEROKU RESPONSE: " + chunk);
} catch (err) {
console.log(err.message);
}
});
}).on('error', function(err) {
console.log("Error: " + err.message);
});
}, 60 * 30 * 1000); // load every 30 minutes
}
startKeepAlive();
var port = process.env.PORT || 5000;
app.listen(port, function() {
console.log("Listening on " + port);
});