This repository has been archived by the owner on Dec 4, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·70 lines (55 loc) · 1.89 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* This code was created for Printr B.V. It is open source under the formide-client package.
* Copyright (c) 2015, All rights reserved, http://printr.nl
*/
/*
* This is the bootstrap of formide-client. It kicks off the formide-client src
* and loads the src modules. After that, all user installed modules are loaded. Finally,
* all loaded modules are activated via the moduleManager.activateLoadedModules function.
*/
console.time('boot time');
// Dependencies
pkg = require('./package.json');
var moduleConfig = null;
try {
moduleConfig = require('./modules.json');
}
catch(e) {
console.error('Could not load modules.json', e);
process.exit(1);
}
// set default env
if (!process.env.NODE_ENV)
process.env.NODE_ENV = 'production';
/**
* Handle exceptions
* @param error
*/
function handleException (error) {
console.error((new Date).toUTCString() + ' uncaughtException:', error.message)
console.error(error.stack);
if (error.message.indexOf('ECONNRESET') > -1) {
console.error('Caught ECONNRESET, not exiting...')
} else {
process.exit(1)
}
}
// catch uncaught connection errors
process.on('uncaughtException', handleException)
// Load formide-client src file
const initFormide = require('./src/FormideClient');
initFormide().then((formideClient) => {
// Log awesome app starter logo
require('./src/utils/logLogo');
// Log app header
formideClient.log.info('==============================================');
formideClient.log.info('Starting formide-client v' + pkg.version + ' as ' + process.env.NODE_ENV);
formideClient.log.info('==============================================');
// Load modules
for (var module in moduleConfig.modules) {
formideClient.moduleManager.loadModule(moduleConfig.modules[module].path, module);
}
// Activate all loaded modules
formideClient.moduleManager.activateLoadedModules();
console.timeEnd('boot time');
}).catch(handleException)