mirror of https://github.com/aruppi/aruppi-api.git
Improved app start
- now showing real address - unix socket support - string correctionspull/1/head
parent
31f34a7c5f
commit
97a6c81341
@ -1,8 +1,20 @@
|
|||||||
const app = require('./app');
|
const app = require('./app');
|
||||||
const port = process.env.PORT || 5000;
|
const port = process.env.PORT || 5000;
|
||||||
|
const addr = isNaN(port) ?
|
||||||
|
'' :
|
||||||
|
(process.env.ADDR || '0.0.0.0');
|
||||||
|
|
||||||
app.listen(port, () => {
|
server = app.listen(port, addr, () => {
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.log(`\n🚀 ... Listening: http://localhost:${port}/api/v2`);
|
console.log(`\n🚀 ... Listening: ${addr}${addr ? '\:' : 'unix://'}${port}`);
|
||||||
/* eslint-enable no-console */
|
/* eslint-enable no-console */
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function shutdown() {
|
||||||
|
server.close(); // socket file is automatically removed here
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
process.on('SIGINT', shutdown);
|
||||||
|
process.on('SIGQUIT', shutdown);
|
||||||
|
process.on('SIGTERM', shutdown);
|
||||||
|
Loading…
Reference in New Issue