Fixed seqelize logging without winston

pull/3/head
Trivernis 5 years ago
parent 61451882aa
commit 9b9d71998b

@ -59,6 +59,7 @@ class App {
const force = fsx.existsSync("sqz-force"); const force = fsx.existsSync("sqz-force");
logger.info(`Syncinc database. Sequelize Table force: ${force}.`); logger.info(`Syncinc database. Sequelize Table force: ${force}.`);
await this.sequelize.sync({force, logging: (msg) => logger.silly(msg)}); await this.sequelize.sync({force, logging: (msg) => logger.silly(msg)});
this.sequelize.options.logging = (msg) => logger.silly(msg);
logger.info("Setting up socket.io"); logger.info("Setting up socket.io");
await routes.ioListeners(this.io); await routes.ioListeners(this.io);
this.io.adapter(socketIoRedis()); this.io.adapter(socketIoRedis());

@ -31,22 +31,23 @@ if (cluster.isMaster) {
}, 1000); }, 1000);
const log = (msg: string) => { const log = (msg: string) => {
process.stdout.write(" ".padEnd(50) + "\r"); process.stdout.write(" ".padEnd(100) + "\r");
process.stdout.write(msg); process.stdout.write(msg);
process.stdout.write( process.stdout.write(
`[C] W: ${clusterData.workerCount()}, Rq: ${clusterData.reqCount}, Mem: ${(() => { `W: ${clusterData.workerCount()},R: ${clusterData.reqCount},M: ${(() => {
let usageString = ""; let usageString = "";
for (const [key, value] of Object.entries(clusterData.workerRes)) { for (const [key, value] of Object.entries(clusterData.workerRes)) {
usageString += `[${key}] ${ usageString += `${
Math.round((value as IResourceUsage).mem.heapUsed / 10000) / 100}MB,`.padEnd(13); Math.round((value as IResourceUsage).mem.heapUsed / 100000) / 10}MB,`.padEnd(8);
} }
return usageString; return usageString;
})()}`.padEnd(49) + "\r"); })()}`.padEnd(99) + "\r");
}; };
cluster.settings.silent = true; cluster.settings.silent = true;
cluster.on("exit", (worker, code, signal) => { cluster.on("exit", (worker, code, signal) => {
log(`[CLUSTER-M] Worker ${worker.process.pid} died!\n`); log(`[CLUSTER-M] Worker ${worker.process.pid} died!\n`);
delete clusterData.workerRes[worker.id];
log("[CLUSTER-M] Starting new worker\n"); log("[CLUSTER-M] Starting new worker\n");
cluster.fork(); cluster.fork();
}); });

Loading…
Cancel
Save