Agent Host changes for agents/nodejs-express-rest-api-orm-swagger
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
require('dotenv').config();
|
||||
|
||||
const app = require('./app');
|
||||
const { sequelize } = require('./models');
|
||||
|
||||
const port = Number(process.env.PORT || 8765);
|
||||
|
||||
async function start() {
|
||||
await sequelize.authenticate();
|
||||
const server = app.listen(port, () => {
|
||||
console.log(`REST API listening on http://localhost:${port}`);
|
||||
});
|
||||
|
||||
const shutdown = async () => {
|
||||
server.close(async () => {
|
||||
await sequelize.close();
|
||||
process.exit(0);
|
||||
});
|
||||
};
|
||||
process.on('SIGINT', shutdown);
|
||||
process.on('SIGTERM', shutdown);
|
||||
}
|
||||
|
||||
start().catch((error) => {
|
||||
console.error('Unable to connect to the database:', error.message);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in New Issue
Block a user