0
0
This commit is contained in:
Aya Morisawa 2016-12-31 03:09:31 +09:00
parent 58433bcb97
commit 6bc3cc2c16
2 changed files with 2 additions and 31 deletions

View File

@ -18,7 +18,7 @@ const portUsed = require('tcp-port-used');
const isRoot = require('is-root');
import ProgressBar from './utils/cli/progressbar';
import initdb from './db/mongodb';
import checkDependencies from './utils/checkDependencies';
import DependencyChecker from './utils/dependencyChecker';
// Init babel
require('babel-core/register');
@ -175,7 +175,7 @@ async function init(): Promise<State> {
configLogger.info('Successfully loaded');
configLogger.info(`maintainer: ${config.maintainer}`);
checkDependencies();
new DependencyChecker().checkAll();
if (process.platform === 'linux' && !isRoot() && config.port < 1024) {
Logger.error('You need root privileges to listen on port below 1024 on Linux');

View File

@ -1,29 +0,0 @@
import Logger from './logger';
import { exec } from 'shelljs';
export default function(): void {
checkDependency('Node.js', 'node -v', x => x.match(/^v(.*)\r?\n$/));
checkDependency('npm', 'npm -v', x => x.match(/^(.*)\r?\n$/));
checkDependency('MongoDB', 'mongo --version', x => x.match(/^MongoDB shell version: (.*)\r?\n$/));
checkDependency('Redis', 'redis-server --version', x => x.match(/v=([0-9\.]*)/));
}
function checkDependency(serviceName: string, command: string, transform: (x: string) => RegExpMatchArray): void {
const code = {
success: 0,
notFound: 127
};
let logger = new Logger('Deps');
const x = exec(command, { silent: true }) as any;
if (x.code === code.success) {
let ver = transform(x.stdout);
if (ver != null) {
logger.info(`${serviceName} ${ver[1]} found`);
} else {
logger.warn(`${serviceName} not found`);
logger.warn(`Regexp used for version check of ${serviceName} is probably messed up`);
}
} else if (x.code === code.notFound) {
logger.warn(`${serviceName} not found`);
}
}