Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/renderer/lib/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,31 @@ export async function getSpecs() {

// Physical CPU cores check
try {
specs.cpuCores = os.cpus().length;

const res = (await execAsync('lscpu -p | egrep -v "^#" | sort -u -t, -k 2,4 | wc -l')).stdout;
specs.cpuCores = parseInt(res.trim(), 10);
} catch(e) {
console.error('Error getting CPU cores:', e);
}

// TODO: These commands might silently fail
// But if they do, it means something wasn't right to begin with
try {
const memoryInfo = await getMemoryInfo();
specs.ramGB = memoryInfo.totalGB;
if (os.platform() === 'darwin') {
specs.ramGB = Math.round(os.totalmem() / 1024 / 1024 / 1024 * 100) / 100;
}else{
const memoryInfo = await getMemoryInfo();
specs.ramGB = memoryInfo.totalGB;
}
} catch (e) {
console.error('Error reading /proc/meminfo:', e);
}

// KVM check
try {
if (os.platform() === 'darwin') {
specs.kvmEnabled = true;
}
const cpuInfo = fs.readFileSync('/proc/cpuinfo', 'utf8');
if ((cpuInfo.includes('vmx') || cpuInfo.includes('svm')) && fs.existsSync('/dev/kvm')) {
specs.kvmEnabled = true;
Expand All @@ -67,7 +75,12 @@ export async function getSpecs() {

// Docker Compose plugin check with version validation
try {
const { stdout: dockerComposeOutput } = await execAsync('docker compose version');
let dockerComposeOutput: string;
if (os.platform() === 'darwin') {
({ stdout: dockerComposeOutput } = await execAsync('docker-compose version'));
} else {
({ stdout: dockerComposeOutput } = await execAsync('docker compose version'));
}
if (dockerComposeOutput) {
// Example output: "Docker Compose version v2.35.1"
// Example output 2: "Docker Compose version 2.36.2"
Expand Down Expand Up @@ -95,8 +108,12 @@ export async function getSpecs() {

// Docker user group check
try {
const userGroups = (await execAsync('id -Gn')).stdout;
specs.dockerIsInUserGroups = userGroups.split(/\s+/).includes('docker');
if (os.platform() === 'darwin') {
specs.dockerIsInUserGroups = true;
}else{
const userGroups = (await execAsync('id -Gn')).stdout;
specs.dockerIsInUserGroups = userGroups.split(/\s+/).includes('docker');
}
} catch (e) {
console.error('Error checking user groups for docker:', e);
}
Expand Down