mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-30 08:13:07 +02:00
Extract MachineInfo
This commit is contained in:
parent
2fd6ddf8ee
commit
7e4091c779
2 changed files with 15 additions and 8 deletions
10
src/index.ts
10
src/index.ts
|
@ -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
13
src/utils/machineInfo.ts
Normal 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)`);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue