forked from fzaninotto/screenshot-as-a-service
-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
41 lines (35 loc) · 1.1 KB
/
app.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
require('newrelic');
/**
* Module dependencies.
*/
var config = require('config');
var express = require('express');
var RasterizerService = require('./lib/rasterizerService');
var FileCleanerService = require('./lib/fileCleanerService');
if (process.env.PORT) {
config.server.port = process.env.PORT;
}
process.on('uncaughtException', function (err) {
console.error("[uncaughtException]", err);
process.exit(1);
});
process.on('SIGTERM', function () {
process.exit(0);
});
process.on('SIGINT', function () {
process.exit(0);
});
// web service
var app = express();
app.configure(function(){
app.use(express.static(__dirname + '/public'))
app.use(app.router);
app.set('rasterizerService', new RasterizerService(config.rasterizer).startService());
app.set('fileCleanerService', new FileCleanerService(config.cache.lifetime));
});
app.configure('development', function() {
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
require('./routes')(app, config.server.useCors);
app.listen(config.server.port);
console.log('Express server listening on port ' + config.server.port);