1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-01 03:15:58 +03:00

feat: add total RAM data to the checking script

This commit is contained in:
louistiti 2022-11-08 20:10:46 +08:00
parent 303ebea3f3
commit 86852a8cac
2 changed files with 22 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import getos from 'getos'
import { version } from '@@/package.json'
import { LogHelper } from '@/helpers/log-helper'
import { OSHelper } from '@/helpers/os-helper'
import {
PYTHON_BRIDGE_BIN_PATH,
TCP_SERVER_BIN_PATH,
@ -30,6 +31,7 @@ dotenv.config()
try {
const nodeMinRequiredVersion = '16'
const npmMinRequiredVersion = '5'
const minimumRequiredRAM = 4
const flitePath = 'bin/flite/flite'
const coquiLanguageModelPath = 'bin/coqui/huge-vocabulary.scorer'
const amazonPath = 'core/config/voice/amazon.json'
@ -129,7 +131,7 @@ dotenv.config()
* Environment checking
*/
LogHelper.info('OS')
LogHelper.info('Environment')
const osInfo = {
type: os.type(),
@ -140,6 +142,16 @@ dotenv.config()
osName: osName(),
distro: null
}
const totalRAMInGB = OSHelper.getTotalRAM()
if (totalRAMInGB < minimumRequiredRAM) {
report.can_run.v = false
LogHelper.error(
`Total RAM: ${totalRAMInGB} GB. Leon needs at least ${minimumRequiredRAM} GB of RAM`
)
} else {
LogHelper.success(`Total RAM: ${totalRAMInGB} GB`)
}
if (osInfo.platform === 'linux') {
getos((e, os) => {
@ -151,6 +163,7 @@ dotenv.config()
}
pastebinData.environment.osDetails = osInfo
pastebinData.environment.totalRAMInGB = totalRAMInGB
;(
await Promise.all([
command('node --version', { shell: true }),

View File

@ -118,4 +118,12 @@ export class OSHelper {
public static getNumberOfCPUCores(): number {
return os.cpus().length
}
/**
* Get the total amount of memory (in GB) on your machine
* @example getTotalRAM() // 4
*/
public static getTotalRAM(): number {
return Number((os.totalmem() / (1_024 * 1_024 * 1_024)).toFixed(2))
}
}