From 2346690cad45e5aa83bc0571d145fc54b2b036cf Mon Sep 17 00:00:00 2001 From: Cris Stringfellow <22254235+crislin2046@users.noreply.github.com> Date: Sun, 15 Jan 2023 02:19:38 +0800 Subject: [PATCH 1/6] Remove test build --- scripts/build_only.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build_only.sh b/scripts/build_only.sh index 52505a6..a33551b 100755 --- a/scripts/build_only.sh +++ b/scripts/build_only.sh @@ -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 From 6592dc968df03e6b88a0853c3fc7396d7665d1dd Mon Sep 17 00:00:00 2001 From: Cris Stringfellow <22254235+crislin2046@users.noreply.github.com> Date: Sun, 15 Jan 2023 02:19:38 +0800 Subject: [PATCH 2/6] 2.7.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index ba0e94c..627d51f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "diskernet", - "version": "2.7.1", + "version": "2.7.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "diskernet", - "version": "2.7.1", + "version": "2.7.2", "license": "PolyForm Strict 1.0", "dependencies": { "@667/ps-list": "^1.1.3", diff --git a/package.json b/package.json index 812b4ea..094511a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "diskernet", - "version": "2.7.1", + "version": "2.7.2", "type": "module", "description": "Library server and an archivist browser controller.", "main": "src/app.js", From 6b707c03472df7d13d90e84073d9fe43d0890ba1 Mon Sep 17 00:00:00 2001 From: Cris Stringfellow <22254235+crislin2046@users.noreply.github.com> Date: Sun, 15 Jan 2023 02:20:15 +0800 Subject: [PATCH 3/6] Remove test build --- .npm.release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.npm.release b/.npm.release index 65e2464..ba5bc21 100644 --- a/.npm.release +++ b/.npm.release @@ -1 +1 @@ -Sun Jan 15 01:13:51 CST 2023 +Sun Jan 15 02:20:06 CST 2023 From d06feb73030c5673a82694fd809f0e485d6a0518 Mon Sep 17 00:00:00 2001 From: Cris Stringfellow <22254235+crislin2046@users.noreply.github.com> Date: Sun, 15 Jan 2023 02:20:15 +0800 Subject: [PATCH 4/6] 2.8.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 627d51f..fd9040e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "diskernet", - "version": "2.7.2", + "version": "2.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "diskernet", - "version": "2.7.2", + "version": "2.8.0", "license": "PolyForm Strict 1.0", "dependencies": { "@667/ps-list": "^1.1.3", diff --git a/package.json b/package.json index 094511a..c5ef41a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "diskernet", - "version": "2.7.2", + "version": "2.8.0", "type": "module", "description": "Library server and an archivist browser controller.", "main": "src/app.js", From 4deb359af8b73c8d8f53fe5a71ad65baf7f9bca9 Mon Sep 17 00:00:00 2001 From: Cris Stringfellow <22254235+crislin2046@users.noreply.github.com> Date: Sun, 15 Jan 2023 14:50:31 +0800 Subject: [PATCH 5/6] Path root works --- src/archivist.js | 2 +- src/common.js | 3 ++- src/libraryServer.js | 7 ++++++- src/root.cjs | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/root.cjs diff --git a/src/archivist.js b/src/archivist.js index 7741b76..2980616 100644 --- a/src/archivist.js +++ b/src/archivist.js @@ -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 = { diff --git a/src/common.js b/src/common.js index f680f4c..45df292 100644 --- a/src/common.js +++ b/src/common.js @@ -2,6 +2,7 @@ import path from 'path'; import {fileURLToPath} from 'url'; import fs from 'fs'; import os from 'os'; +import root from './root.cjs'; const DEEB = false; @@ -75,7 +76,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 = root.APP_ROOT; //export const APP_ROOT = path.dirname(fileURLToPath(import.meta.url)); export const sleep = ms => new Promise(res => setTimeout(res, ms)); diff --git a/src/libraryServer.js b/src/libraryServer.js index 4a5fb8b..a11523f 100644 --- a/src/libraryServer.js +++ b/src/libraryServer.js @@ -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; diff --git a/src/root.cjs b/src/root.cjs new file mode 100644 index 0000000..44a03a9 --- /dev/null +++ b/src/root.cjs @@ -0,0 +1,14 @@ +const path = require('path'); +const url = require('url'); + +const file = __filename; +const dir = path.dirname(file); + +console.log({file, dir}); + +module.exports = { + APP_ROOT: dir, + dir, + file +} + From a386ec5bc9f751b8de38643dc586c8b9d31aa05a Mon Sep 17 00:00:00 2001 From: Cris Stringfellow <22254235+crislin2046@users.noreply.github.com> Date: Sun, 15 Jan 2023 15:07:51 +0800 Subject: [PATCH 6/6] Resolved cross-format APP ROOT issue --- src/common.js | 10 ++++++---- src/root.cjs | 5 +++-- src/root.js | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 src/root.js diff --git a/src/common.js b/src/common.js index 45df292..fe45657 100644 --- a/src/common.js +++ b/src/common.js @@ -2,7 +2,7 @@ import path from 'path'; import {fileURLToPath} from 'url'; import fs from 'fs'; import os from 'os'; -import root from './root.cjs'; +import {APP_ROOT as __ROOT} from './root.js'; const DEEB = false; @@ -14,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; @@ -75,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 = root.APP_ROOT; -//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)); diff --git a/src/root.cjs b/src/root.cjs index 44a03a9..9d3dda9 100644 --- a/src/root.cjs +++ b/src/root.cjs @@ -3,11 +3,12 @@ const url = require('url'); const file = __filename; const dir = path.dirname(file); +const APP_ROOT = dir; -console.log({file, dir}); +console.log({APP_ROOT}); module.exports = { - APP_ROOT: dir, + APP_ROOT, dir, file } diff --git a/src/root.js b/src/root.js new file mode 100644 index 0000000..a92afd4 --- /dev/null +++ b/src/root.js @@ -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; +