Skip to content

Commit

Permalink
Merge pull request #168 from dosyago/better-starutp
Browse files Browse the repository at this point in the history
Better startup
  • Loading branch information
o0101 authored Jul 23, 2023
2 parents cc10614 + ec7f2a4 commit 0d94d86
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 60 deletions.
69 changes: 42 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "diskernet",
"version": "2.9.0",
"version": "3.0.0",
"type": "module",
"description": "Library server and an archivist browser controller.",
"main": "src/app.js",
Expand Down Expand Up @@ -41,7 +41,7 @@
"library"
],
"author": "@dosy",
"license": "PolyForm Strict 1.0",
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/dosyago/DiskerNet/issues"
},
Expand Down
15 changes: 9 additions & 6 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Your HTML Library</title>
<link rel=stylesheet href=/style.css>
<title>Your Personal Search Engine and Archive</title>
<link rel=stylesheet href=style.css>
<header>
<h1><a href=/>22120</a> &mdash; Internet Offline Library</h1>
<h1><a href=/>DiskerNet</a> &mdash; Personal Web Search and Archive</h1>
</header>
<p>
View <a href=/archive_index.html>the index</a>
View <a href=/archive_index.html>your index</a>
</p>
<!--
<form method=POST action=/crawl>
Expand Down Expand Up @@ -147,7 +147,7 @@ <h1><a href=/>22120</a> &mdash; Internet Offline Library</h1>
<form method=GET action=/search>
<fieldset class=search>
<legend>Search your archive</legend>
<input class=search type=search name=query placeholder="search your library">
<input autofocus class=search type=search name=query placeholder="search your library">
<button>Search</button>
</fieldset>
</form>
Expand Down Expand Up @@ -236,8 +236,11 @@ <h1><a href=/>22120</a> &mdash; Internet Offline Library</h1>
<button disabled>Publish</button>
</fieldset>
</form>
<p>
Notice a bug? <a href=https://github.com/dosyago/DiskerNet/issues>Open an issue!</a>
</p>
<footer>
<cite>
<a rel=author href=https://github.com/crisdosyago/22120>22120 GitHub</a>
<a rel=author href=https://github.com/dosyago/DiskerNet>DiskerNet GitHub</a>
</cite>
</footer>
7 changes: 5 additions & 2 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
background: lavenderblush;
}
body {
display: table;
margin: 0 auto 0 min(10%, 5em);
background: white;
padding: 0.5em;
border-bottom: 1px solid purple;
max-width: min(777px, 80%);
overflow-x: hidden;
}
header {
font-size: smaller;
Expand Down Expand Up @@ -80,7 +80,7 @@

input[type="number"] {
text-align: right;
]
}

input.search {
flex-grow: 1;
Expand All @@ -99,3 +99,6 @@
.grey {
color: grey;
}
a {
word-break: break-word;
}
24 changes: 24 additions & 0 deletions run.cjs
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' });

6 changes: 0 additions & 6 deletions run.sh

This file was deleted.

11 changes: 8 additions & 3 deletions scripts/compile.sh
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 .
1 change: 1 addition & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ async function killChrome(wait = true) {
}

async function cleanup(reason, err, {exit = false} = {}) {
console.log(`Shutting down everything because of an error!`);
console.log(`Cleanup called on reason: ${reason}`, err);

if ( quitting ) {
Expand Down
3 changes: 2 additions & 1 deletion src/archivist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,8 @@
obj.id = id;
return obj;
} catch(e) {
console.log({obj, index:State.Index, e, ndx, flex, fuzz});
DEBUG.verboseSlow && console.log({obj, index:State.Index, e, ndx, flex, fuzz});
console.error("Error", e);
return obj;
}
});
Expand Down
1 change: 1 addition & 0 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {APP_ROOT as __ROOT} from './root.js';
const DEEB = false;

export const DEBUG = {
debugSec: false,
askFirst: true,
verboseSlow: process.env.VERBOSE_DEBUG_22120 || DEEB,
debug: process.env.DEBUG_22120 || DEEB,
Expand Down
Loading

0 comments on commit 0d94d86

Please sign in to comment.