Skip to content

Commit

Permalink
Merge pull request #145 from dosyago/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
o0101 authored Jan 15, 2023
2 parents 7b1ed07 + a386ec5 commit f1e5db0
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .npm.release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Sun Jan 15 01:13:51 CST 2023
Sun Jan 15 02:20:06 CST 2023
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "diskernet",
"version": "2.7.1",
"version": "2.8.0",
"type": "module",
"description": "Library server and an archivist browser controller.",
"main": "src/app.js",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

./node_modules/.bin/esbuild src/app.js --bundle --outfile=dist/diskernet.mjs --format=esm --platform=node --minify --analyze
./node_modules/.bin/esbuild src/app.js --bundle --outfile=build/out.cjs --platform=node --minify --analyze
./node_modules/.bin/esbuild src/app.js --bundle --outfile=build/test.cjs --platform=node
#./node_modules/.bin/esbuild src/app.js --bundle --outfile=build/test.cjs --platform=node
echo "#!/usr/bin/env node" > build/diskernet.cjs
cat build/out.cjs >> build/diskernet.cjs
chmod +x build/diskernet.cjs
Expand Down
2 changes: 1 addition & 1 deletion src/archivist.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@
async function collect({chrome_port:port, mode} = {}) {
const {library_path} = args;
const exitHandlers = [];
process.on('SIGUSR2', runHandlers);
process.on('beforeExit', runHandlers);
process.on('SIGUSR2', code => runHandlers(code, 'SIGUSR2', {exit: true}));
process.on('exit', code => runHandlers(code, 'exit', {exit: true}));
State.connection = State.connection || await connect({port});
State.onExit = {
Expand Down
9 changes: 6 additions & 3 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';
import {fileURLToPath} from 'url';
import fs from 'fs';
import os from 'os';
import {APP_ROOT as __ROOT} from './root.js';

const DEEB = false;

Expand All @@ -13,6 +14,10 @@ export const DEBUG = {
}
export const SHOW_FETCH = false;

if ( DEBUG.debug ) {
console.log({APP_ROOT});
}

// server related
export const PUBLIC_SERVER = true;

Expand Down Expand Up @@ -74,9 +79,7 @@ export const SNIP_CONTEXT = 31;

export const NO_SANDBOX = (process.env.DEBUG_22120 && process.env.SET_22120_NO_SANDBOX) || false;

//export const APP_ROOT = '.';
export const APP_ROOT = path.dirname(process.argv[0]);
//export const APP_ROOT = path.dirname(fileURLToPath(import.meta.url));
export const APP_ROOT = __ROOT

export const sleep = ms => new Promise(res => setTimeout(res, ms));

Expand Down
7 changes: 6 additions & 1 deletion src/libraryServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ async function start({server_port}) {
throw err;
}
upAt = new Date;
say({server_up:{upAt,port}});
say({server_up:{upAt,port,
...(DEBUG.verboseSlow ? {
static_site_path: SITE_PATH,
app_root: APP_ROOT,
} : {})
}});
});
} catch(e) {
running = false;
Expand Down
15 changes: 15 additions & 0 deletions src/root.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const path = require('path');
const url = require('url');

const file = __filename;
const dir = path.dirname(file);
const APP_ROOT = dir;

console.log({APP_ROOT});

module.exports = {
APP_ROOT,
dir,
file
}

22 changes: 22 additions & 0 deletions src/root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import path from 'path';
import url from 'url';

let root;
let esm = false;

try {
console.log(__dirname, __filename);
} catch(e) {
esm = true;
}

if ( ! esm ) {
root = require('./root.cjs').APP_ROOT;
} else {
root = path.dirname(url.fileURLToPath(import.meta.url));
}

console.log({root});

export const APP_ROOT = root;

0 comments on commit f1e5db0

Please sign in to comment.