-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from dosyago/better-starutp
Better startup
- Loading branch information
Showing
11 changed files
with
109 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}`, 'src/app.js'], { stdio: 'inherit' }); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
./scripts/build_only.sh | ||
|
||
unset npm_config_prefix | ||
source $HOME/.nvm/nvm.sh | ||
nvm use --lts | ||
PKG=$(which pkg) | ||
if [ -z $PKG ]; then | ||
npm i -g pkg@latest | ||
PKG=$(which pkg) | ||
fi | ||
|
||
./scripts/build_only.sh | ||
|
||
pkg --compress GZip . | ||
$PKG --compress GZip . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.