Extract MachineInfo

This commit is contained in:
Aya Morisawa 2016-12-31 03:19:59 +09:00
parent 2fd6ddf8ee
commit 7e4091c779
2 changed files with 15 additions and 8 deletions

View file

@ -18,6 +18,7 @@ const portUsed = require('tcp-port-used');
const isRoot = require('is-root'); const isRoot = require('is-root');
import ProgressBar from './utils/cli/progressbar'; import ProgressBar from './utils/cli/progressbar';
import initdb from './db/mongodb'; import initdb from './db/mongodb';
import MachineInfo from './utils/machineInfo';
import DependencyChecker from './utils/dependencyChecker'; import DependencyChecker from './utils/dependencyChecker';
// Init babel // Init babel
@ -158,14 +159,7 @@ async function init(): Promise<State> {
envLogger.warn('Do not use for production purpose'); envLogger.warn('Do not use for production purpose');
} }
// Get machine info MachineInfo.show();
const totalmem = (os.totalmem() / 1024 / 1024 / 1024).toFixed(1);
const freemem = (os.freemem() / 1024 / 1024 / 1024).toFixed(1);
let machineLogger = new Logger('Machine');
machineLogger.info(os.hostname());
machineLogger.info(`CPU: ${os.cpus().length}core`);
machineLogger.info(`MEM: ${totalmem}GB (available: ${freemem}GB)`);
new DependencyChecker().checkAll(); new DependencyChecker().checkAll();
let configLogger = new Logger('Config'); let configLogger = new Logger('Config');

13
src/utils/machineInfo.ts Normal file
View file

@ -0,0 +1,13 @@
import * as os from 'os';
import Logger from './logger';
export default class MachineInfo {
static show() {
const totalmem = (os.totalmem() / 1024 / 1024 / 1024).toFixed(1);
const freemem = (os.freemem() / 1024 / 1024 / 1024).toFixed(1);
let logger = new Logger('Machine');
logger.info(os.hostname());
logger.info(`CPU: ${os.cpus().length}core`);
logger.info(`MEM: ${totalmem}GB (available: ${freemem}GB)`);
}
}