forked from EvilMurlok/simpleServerMonitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (22 loc) · 721 Bytes
/
index.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
const app = require('./server/express/app');
const sequelize = require('./server/sequelize');
const PORT = 9000;
async function assertDatabaseConnectionOk() {
console.log(`Checking database connection...`);
try {
await sequelize.authenticate();
console.log('Database connection OK!');
} catch (error) {
console.log('Unable to connect to the database:');
console.log(error.message);
process.exit(1);
}
}
async function init() {
await assertDatabaseConnectionOk();
console.log(`Starting Sequelize + Express example on port ${PORT}...`);
app.listen(PORT, () => {
console.log(`Express server started on port ${PORT}.`);
});
}
init().then();