1
0
mirror of https://github.com/c9fe/22120.git synced 2024-07-14 23:32:22 +02:00

Path root works

This commit is contained in:
Cris Stringfellow 2023-01-15 14:50:31 +08:00
parent d06feb7303
commit 4deb359af8
No known key found for this signature in database
4 changed files with 23 additions and 3 deletions

View File

@ -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 = {

View File

@ -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));

View File

@ -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;

14
src/root.cjs Normal file
View File

@ -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
}