forked from joshrendek/gulp-aws-splash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
62 lines (41 loc) · 1.1 KB
/
app.js
File metadata and controls
62 lines (41 loc) · 1.1 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
60
61
62
// # app
var path = require('path');
var IoC = require('electrolyte');
var bootable = require('bootable');
var express = require('express');
// change the working directory to the root directory
process.chdir(__dirname);
// dependency injection
IoC.loader(IoC.node(path.join(__dirname, 'boot')));
IoC.loader('igloo', require('igloo'));
// phases
var app = bootable(express());
app.phase(bootable.di.initializers());
app.phase(bootable.di.routes());
app.phase(IoC.create('igloo/server'));
// boot
var logger = IoC.create('igloo/logger');
var settings = IoC.create('igloo/settings');
app.boot(function(err) {
if (err) {
logger.error(err.message);
if (settings.showStack) {
logger.error(err.stack);
}
process.exit(-1);
return;
}
logger.info('app booted');
if (process.send)
process.send('online');
});
// <https://github.com/andrewrk/naught#usage>
process.on('message', function(message) {
// listen for shutdown event
// (cleanup if necessary)
if (message === 'shutdown') {
// performCleanup();
process.exit(0);
}
});
exports = module.exports = app;