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