Skip to content

Commit 0d94d86

Browse files
authored
Merge pull request #168 from dosyago/better-starutp
Better startup
2 parents cc10614 + ec7f2a4 commit 0d94d86

File tree

11 files changed

+109
-60
lines changed

11 files changed

+109
-60
lines changed

package-lock.json

Lines changed: 42 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "diskernet",
3-
"version": "2.9.0",
3+
"version": "3.0.0",
44
"type": "module",
55
"description": "Library server and an archivist browser controller.",
66
"main": "src/app.js",
@@ -41,7 +41,7 @@
4141
"library"
4242
],
4343
"author": "@dosy",
44-
"license": "PolyForm Strict 1.0",
44+
"license": "AGPL-3.0",
4545
"bugs": {
4646
"url": "https://github.com/dosyago/DiskerNet/issues"
4747
},

public/index.html

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<!DOCTYPE html>
22
<meta charset=utf-8>
3-
<title>Your HTML Library</title>
4-
<link rel=stylesheet href=/style.css>
3+
<title>Your Personal Search Engine and Archive</title>
4+
<link rel=stylesheet href=style.css>
55
<header>
6-
<h1><a href=/>22120</a> &mdash; Internet Offline Library</h1>
6+
<h1><a href=/>DiskerNet</a> &mdash; Personal Web Search and Archive</h1>
77
</header>
88
<p>
9-
View <a href=/archive_index.html>the index</a>
9+
View <a href=/archive_index.html>your index</a>
1010
</p>
1111
<!--
1212
<form method=POST action=/crawl>
@@ -147,7 +147,7 @@ <h1><a href=/>22120</a> &mdash; Internet Offline Library</h1>
147147
<form method=GET action=/search>
148148
<fieldset class=search>
149149
<legend>Search your archive</legend>
150-
<input class=search type=search name=query placeholder="search your library">
150+
<input autofocus class=search type=search name=query placeholder="search your library">
151151
<button>Search</button>
152152
</fieldset>
153153
</form>
@@ -236,8 +236,11 @@ <h1><a href=/>22120</a> &mdash; Internet Offline Library</h1>
236236
<button disabled>Publish</button>
237237
</fieldset>
238238
</form>
239+
<p>
240+
Notice a bug? <a href=https://github.com/dosyago/DiskerNet/issues>Open an issue!</a>
241+
</p>
239242
<footer>
240243
<cite>
241-
<a rel=author href=https://github.com/crisdosyago/22120>22120 GitHub</a>
244+
<a rel=author href=https://github.com/dosyago/DiskerNet>DiskerNet GitHub</a>
242245
</cite>
243246
</footer>

public/style.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
background: lavenderblush;
55
}
66
body {
7-
display: table;
87
margin: 0 auto 0 min(10%, 5em);
98
background: white;
109
padding: 0.5em;
1110
border-bottom: 1px solid purple;
1211
max-width: min(777px, 80%);
12+
overflow-x: hidden;
1313
}
1414
header {
1515
font-size: smaller;
@@ -80,7 +80,7 @@
8080

8181
input[type="number"] {
8282
text-align: right;
83-
]
83+
}
8484

8585
input.search {
8686
flex-grow: 1;
@@ -99,3 +99,6 @@
9999
.grey {
100100
color: grey;
101101
}
102+
a {
103+
word-break: break-word;
104+
}

run.cjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env node
2+
3+
const os = require('os');
4+
const { spawn } = require('child_process');
5+
6+
// Checking if node_modules directory exists
7+
const fs = require('fs');
8+
const path = require('path');
9+
10+
if (!fs.existsSync(path.join(process.cwd(), 'node_modules'))) {
11+
spawn('npm', ['i'], { stdio: 'inherit' });
12+
}
13+
14+
// Getting the total system memory
15+
const totalMemory = os.totalmem();
16+
17+
// Allocating 90% of the total memory
18+
const memoryAllocation = Math.floor((totalMemory / (1024 * 1024)) * 0.8); // Converted bytes to MB and took 90% of it
19+
20+
console.log(`Index can use up to: ${memoryAllocation}MB RAM`);
21+
22+
// Running the application
23+
spawn('node', [`--max-old-space-size=${memoryAllocation}`, 'src/app.js'], { stdio: 'inherit' });
24+

run.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

scripts/compile.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#!/usr/bin/env bash
22

3-
./scripts/build_only.sh
4-
53
unset npm_config_prefix
64
source $HOME/.nvm/nvm.sh
75
nvm use --lts
6+
PKG=$(which pkg)
7+
if [ -z $PKG ]; then
8+
npm i -g pkg@latest
9+
PKG=$(which pkg)
10+
fi
11+
12+
./scripts/build_only.sh
813

9-
pkg --compress GZip .
14+
$PKG --compress GZip .

src/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ async function killChrome(wait = true) {
143143
}
144144

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

148149
if ( quitting ) {

src/archivist.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,8 @@
12221222
obj.id = id;
12231223
return obj;
12241224
} catch(e) {
1225-
console.log({obj, index:State.Index, e, ndx, flex, fuzz});
1225+
DEBUG.verboseSlow && console.log({obj, index:State.Index, e, ndx, flex, fuzz});
1226+
console.error("Error", e);
12261227
return obj;
12271228
}
12281229
});

src/common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {APP_ROOT as __ROOT} from './root.js';
77
const DEEB = false;
88

99
export const DEBUG = {
10+
debugSec: false,
1011
askFirst: true,
1112
verboseSlow: process.env.VERBOSE_DEBUG_22120 || DEEB,
1213
debug: process.env.DEBUG_22120 || DEEB,

0 commit comments

Comments
 (0)