forked from tapd8/apig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
39 lines (36 loc) · 972 Bytes
/
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
// global.appConfig = require('./config');
const application = require('./dist');
const Conf = require('conf');
const config = new Conf();
require('./mixin');
module.exports = application;
if (require.main === module) {
// Run the application
const configm = {
rest: {
port: config.get('port') || +process.env.PORT || 3030,
host: config.get('host') || process.env.HOST || 'localhost',
openApiSpec: {
// useful when used with OASGraph to locate your application
setServersFromRequest: true,
},
},
};
application.main(configm, (result) => {
if (result && typeof process.send === 'function'){
process.send({
type: 'status',
data: 'running'
});
}
}).catch(err => {
console.error('Cannot start the application.', err);
process.send({
type: 'status',
data: 'exit',
msg: err.toString()
});
process.exit(1);
});
}
// require('fs').writeFileSync(`${__dirname}/app.pid`, `${process.pid}\n`, { encoding: 'utf-8'});