mirror of
https://github.com/MisskeyIO/misskey
synced 2024-11-23 22:56:49 +09:00
parent
16136c252a
commit
b62203b1f1
17
src/index.ts
17
src/index.ts
@ -14,7 +14,7 @@ import * as portscanner from 'portscanner';
|
|||||||
import isRoot = require('is-root');
|
import isRoot = require('is-root');
|
||||||
import Xev from 'xev';
|
import Xev from 'xev';
|
||||||
import * as program from 'commander';
|
import * as program from 'commander';
|
||||||
import mongo from './db/mongodb';
|
import mongo, { nativeDbConn } from './db/mongodb';
|
||||||
|
|
||||||
import Logger from './misc/logger';
|
import Logger from './misc/logger';
|
||||||
import EnvironmentInfo from './misc/environmentInfo';
|
import EnvironmentInfo from './misc/environmentInfo';
|
||||||
@ -23,6 +23,7 @@ import serverStats from './daemons/server-stats';
|
|||||||
import notesStats from './daemons/notes-stats';
|
import notesStats from './daemons/notes-stats';
|
||||||
import loadConfig from './config/load';
|
import loadConfig from './config/load';
|
||||||
import { Config } from './config/types';
|
import { Config } from './config/types';
|
||||||
|
import { lessThan } from './prelude/array';
|
||||||
|
|
||||||
const clusterLog = debug('misskey:cluster');
|
const clusterLog = debug('misskey:cluster');
|
||||||
const ev = new Xev();
|
const ev = new Xev();
|
||||||
@ -158,11 +159,19 @@ function checkMongoDb(config: Config) {
|
|||||||
mongoDBLogger.info(`Connecting to ${uri}`);
|
mongoDBLogger.info(`Connecting to ${uri}`);
|
||||||
|
|
||||||
mongo.then(() => {
|
mongo.then(() => {
|
||||||
|
nativeDbConn().then(db => db.admin().serverInfo()).then(x => x.version).then((version: string) => {
|
||||||
|
mongoDBLogger.info(`Version: ${version}`);
|
||||||
|
if (lessThan(version.split('.').map(x => parseInt(x, 10)), [3, 6])) {
|
||||||
|
mongoDBLogger.error(`MongoDB version is less than 3.6. Please upgrade it.`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mongoDBLogger.succ('Connectivity confirmed');
|
mongoDBLogger.succ('Connectivity confirmed');
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
mongoDBLogger.error(err.message);
|
mongoDBLogger.error(err.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawnWorkers(limit: number) {
|
function spawnWorkers(limit: number) {
|
||||||
|
@ -49,3 +49,11 @@ export function groupBy<T>(f: (x: T, y: T) => boolean, xs: T[]): T[][] {
|
|||||||
export function groupOn<T, S>(f: (x: T) => S, xs: T[]): T[][] {
|
export function groupOn<T, S>(f: (x: T) => S, xs: T[]): T[][] {
|
||||||
return groupBy((a, b) => f(a) === f(b), xs);
|
return groupBy((a, b) => f(a) === f(b), xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function lessThan(xs: number[], ys: number[]): boolean {
|
||||||
|
for (let i = 0; i < Math.min(xs.length, ys.length); i++) {
|
||||||
|
if (xs[i] < ys[i]) return true;
|
||||||
|
if (xs[i] > ys[i]) return false;
|
||||||
|
}
|
||||||
|
return xs.length < ys.length;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user