1
0
mirror of https://github.com/c9fe/22120.git synced 2024-10-03 21:57:13 +02:00

3.0.xx new version with fixes

This commit is contained in:
Cris Stringfellow 2023-07-23 10:16:35 +08:00
parent e54ad4490f
commit 2d7c53e680
No known key found for this signature in database
2 changed files with 25 additions and 1 deletions

24
global-run.cjs Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env node
const os = require('os');
const { spawn } = require('child_process');
// Checking if node_modules directory exists
const fs = require('fs');
const path = require('path');
if (!fs.existsSync(path.join(process.cwd(), 'node_modules'))) {
spawn('npm', ['i'], { stdio: 'inherit' });
}
// Getting the total system memory
const totalMemory = os.totalmem();
// Allocating 90% of the total memory
const memoryAllocation = Math.floor((totalMemory / (1024 * 1024)) * 0.8); // Converted bytes to MB and took 90% of it
console.log(`Index can use up to: ${memoryAllocation}MB RAM`);
// Running the application
spawn('node', [`--max-old-space-size=${memoryAllocation}`, 'build/diskernet.mjs'], { stdio: 'inherit' });

View File

@ -6,7 +6,7 @@
"main": "src/app.js",
"module": "dist/diskernet.mjs",
"bin": {
"diskernet": "./run.cjs"
"diskernet": "./global-run.cjs"
},
"scripts": {
"start": "node src/app.js",