mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 01:13:09 +02:00
✨
This commit is contained in:
parent
58433bcb97
commit
6bc3cc2c16
2 changed files with 2 additions and 31 deletions
|
@ -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');
|
||||
|
|
|
@ -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`);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue