2022-02-24 10:27:06 +00:00
|
|
|
import { configure, getLogger } from 'log4js';
|
2022-03-07 08:36:13 +00:00
|
|
|
import Instance from './models/Instance';
|
2022-03-07 12:50:05 +00:00
|
|
|
import db from './models/db';
|
2022-02-16 08:20:50 +00:00
|
|
|
|
|
|
|
(async () => {
|
2022-02-17 13:09:12 +00:00
|
|
|
configure({
|
|
|
|
appenders: {
|
|
|
|
console: { type: 'console' },
|
|
|
|
},
|
|
|
|
categories: {
|
2022-02-24 13:23:35 +00:00
|
|
|
default: { level: 'debug', appenders: ['console'] },
|
2022-02-17 13:09:12 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
const log = getLogger('Main');
|
2022-02-22 11:17:17 +00:00
|
|
|
process.on('unhandledRejection', error => {
|
|
|
|
log.error('UnhandledException: ', error);
|
|
|
|
});
|
2022-03-07 12:50:05 +00:00
|
|
|
const instanceEntries = await db.instance.findMany();
|
|
|
|
if (!instanceEntries.length) {
|
|
|
|
await Instance.start(0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (const instanceEntry of instanceEntries) {
|
|
|
|
await Instance.start(instanceEntry.id);
|
|
|
|
}
|
|
|
|
}
|
2022-02-16 08:20:50 +00:00
|
|
|
})();
|