From 14ddca38751382ae9fe0a2475754c77deaaa1293 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 26 Apr 2020 11:39:15 +0900 Subject: [PATCH] feat(server): Improve boot process --- src/boot/master.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/boot/master.ts b/src/boot/master.ts index 0fcddf67d..10a6843d5 100644 --- a/src/boot/master.ts +++ b/src/boot/master.ts @@ -32,7 +32,7 @@ function greet() { console.log(chalk.keyword('orange')(' If you like Misskey, please donate to support development. https://www.patreon.com/syuilo')); console.log(''); - console.log(chalk`< ${os.hostname()} {gray (PID: ${process.pid.toString()})} >`); + console.log(chalk`--- ${os.hostname()} {gray (PID: ${process.pid.toString()})} ---`); } bootLogger.info('Welcome to Misskey!'); @@ -76,13 +76,13 @@ export async function masterMain() { await spawnWorkers(config.clusterLimit); } + bootLogger.succ(`Now listening on port ${config.port} on ${config.url}`, null, true); + if (!program.noDaemons) { require('../daemons/server-stats').default(); require('../daemons/queue-stats').default(); require('../daemons/janitor').default(); } - - bootLogger.succ(`Now listening on port ${config.port} on ${config.url}`, null, true); } const runningNodejsVersion = process.version.slice(1).split('.').map(x => parseInt(x, 10)); @@ -116,6 +116,8 @@ function showEnvironment(): void { async function init(): Promise { showEnvironment(); + await showMachineInfo(bootLogger); + const nodejsLogger = bootLogger.createSubLogger('nodejs'); nodejsLogger.info(`Version ${runningNodejsVersion.join('.')}`); @@ -125,8 +127,6 @@ async function init(): Promise { process.exit(1); } - await showMachineInfo(bootLogger); - const configLogger = bootLogger.createSubLogger('config'); let config; @@ -146,15 +146,17 @@ async function init(): Promise { configLogger.succ('Loaded'); + const dbLogger = bootLogger.createSubLogger('db'); + // Try to connect to DB try { - bootLogger.info('Connecting database...'); + dbLogger.info('Connecting...'); await initDb(); const v = await getConnection().query('SHOW server_version').then(x => x[0].server_version) - bootLogger.succ(`Connected to database: v${v}`); + dbLogger.succ(`Connected: v${v}`); } catch (e) { - bootLogger.error('Cannot connect to database', null, true); - bootLogger.error(e); + dbLogger.error('Cannot connect', null, true); + dbLogger.error(e); process.exit(1); }