mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-26 22:29:28 +09:00
Refactoring
This commit is contained in:
parent
226c5cc2d6
commit
7f700d42c8
20
src/index.ts
20
src/index.ts
@ -54,12 +54,8 @@ async function masterMain() {
|
|||||||
config = await init();
|
config = await init();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config == null) {
|
|
||||||
Logger.error(chalk.red('Fatal error occurred during initializing :('));
|
Logger.error(chalk.red('Fatal error occurred during initializing :('));
|
||||||
process.exit();
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.info(chalk.green('Successfully initialized :)'));
|
Logger.info(chalk.green('Successfully initialized :)'));
|
||||||
@ -70,7 +66,7 @@ async function masterMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spawnWorkers(() => {
|
spawnWorkers(() => {
|
||||||
Logger.info(chalk.bold.green(`Now listening on port ${loadConfig().port}`));
|
Logger.info(chalk.bold.green(`Now listening on port ${config.port}`));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,8 +92,7 @@ async function init(): Promise<Config> {
|
|||||||
|
|
||||||
let configLogger = new Logger('Config');
|
let configLogger = new Logger('Config');
|
||||||
if (!fs.existsSync(configPath)) {
|
if (!fs.existsSync(configPath)) {
|
||||||
configLogger.error('Configuration not found');
|
throw 'Configuration not found';
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = loadConfig();
|
const config = loadConfig();
|
||||||
@ -106,15 +101,13 @@ async function init(): Promise<Config> {
|
|||||||
configLogger.info(`maintainer: ${config.maintainer}`);
|
configLogger.info(`maintainer: ${config.maintainer}`);
|
||||||
|
|
||||||
if (process.platform === 'linux' && !isRoot() && config.port < 1024) {
|
if (process.platform === 'linux' && !isRoot() && config.port < 1024) {
|
||||||
Logger.error('You need root privileges to listen on port below 1024 on Linux');
|
throw 'You need root privileges to listen on port below 1024 on Linux';
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a port is being used
|
// Check if a port is being used
|
||||||
/* https://github.com/stdarg/tcp-port-used/issues/3
|
/* https://github.com/stdarg/tcp-port-used/issues/3
|
||||||
if (await portUsed.check(config.port)) {
|
if (await portUsed.check(config.port)) {
|
||||||
Logger.error(`Port ${config.port} is already used`);
|
throw `Port ${config.port} is already used`;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -125,8 +118,7 @@ async function init(): Promise<Config> {
|
|||||||
mongoDBLogger.info('Successfully connected');
|
mongoDBLogger.info('Successfully connected');
|
||||||
db.close();
|
db.close();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
mongoDBLogger.error(e);
|
throw e;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
|
Loading…
Reference in New Issue
Block a user