Q2TG/src/index.ts

35 lines
831 B
TypeScript
Raw Normal View History

import { configure, getLogger } from 'log4js';
import Instance from './models/Instance';
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');
if (!process.versions.node.startsWith('18.')) {
log.warn('当前正在使用的 Node.JS 版本为', process.versions.node, ',未经测试');
}
process.on('unhandledRejection', error => {
log.error('UnhandledException: ', error);
});
const instanceEntries = await db.instance.findMany();
if (!instanceEntries.length) {
2024-01-28 07:50:40 +00:00
await Instance.start(0);
}
else {
for (const instanceEntry of instanceEntries) {
2024-01-28 07:50:40 +00:00
await Instance.start(instanceEntry.id);
}
}
2022-02-16 08:20:50 +00:00
})();