Add gate at start for chrome - closes #139
This commit is contained in:
parent
a333dc7a79
commit
823da1d925
|
@ -19,6 +19,7 @@
|
|||
"ndx-query": "^1.0.1",
|
||||
"ndx-serializable": "^1.0.0",
|
||||
"node-fetch": "latest",
|
||||
"ps-list": "^8.1.1",
|
||||
"ukkonen": "^1.4.0",
|
||||
"ws": "latest"
|
||||
},
|
||||
|
@ -2189,6 +2190,17 @@
|
|||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/ps-list": {
|
||||
"version": "8.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ps-list/-/ps-list-8.1.1.tgz",
|
||||
"integrity": "sha512-OPS9kEJYVmiO48u/B9qneqhkMvgCxT+Tm28VCEJpheTpl8cJ0ffZRRNgS5mrQRTrX5yRTpaJ+hRDeefXYmmorQ==",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/pstree.remy": {
|
||||
"version": "1.1.8",
|
||||
"resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
"ndx-query": "^1.0.1",
|
||||
"ndx-serializable": "^1.0.0",
|
||||
"node-fetch": "latest",
|
||||
"ps-list": "^8.1.1",
|
||||
"ukkonen": "^1.4.0",
|
||||
"ws": "latest"
|
||||
},
|
||||
|
|
31
src/app.js
31
src/app.js
|
@ -1,7 +1,11 @@
|
|||
import fs from 'fs';
|
||||
import ChildProcess from 'child_process';
|
||||
import readline from 'readline';
|
||||
import util from 'util';
|
||||
import {stdin as input, stdout as output} from 'process';
|
||||
|
||||
import ChromeLauncher from 'chrome-launcher';
|
||||
import psList from 'ps-list';
|
||||
|
||||
import {DEBUG, sleep, NO_SANDBOX, GO_SECURE} from './common.js';
|
||||
|
||||
|
@ -56,7 +60,32 @@ async function start() {
|
|||
console.log(`Importing dependencies...`);
|
||||
const {launch:ChromeLaunch} = ChromeLauncher;
|
||||
|
||||
await killChrome();
|
||||
let chromeOpen = false;
|
||||
|
||||
const list = await psList();
|
||||
|
||||
chromeOpen = list.some(({name,cmd}) => name.match(/chrome/g) || cmd.match(/chrome/g));
|
||||
|
||||
if ( chromeOpen ) {
|
||||
console.info(`Seems Chrome is open`);
|
||||
if ( DEBUG.askFirst ) {
|
||||
const rl = readline.createInterface({input, output});
|
||||
const question = util.promisify(rl.question).bind(rl);
|
||||
console.info(`\nIf you don't shut down Chrome and restart it under DiskerNet control
|
||||
you will not be able to save or serve your archives.\n`);
|
||||
const answer = await question("Would you like to shutdown Chrome browser now (y/N) ? ");
|
||||
if ( answer?.match(/^y/i) ) {
|
||||
await killChrome();
|
||||
} else {
|
||||
console.log(`OK, not shutting it!\n`);
|
||||
if ( chromeOpen ) {
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await killChrome();
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Removing 22120's existing temporary browser cache if it exists...`);
|
||||
if ( fs.existsSync(args.temp_browser_cache()) ) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import fs from 'fs';
|
|||
import os from 'os';
|
||||
|
||||
export const DEBUG = {
|
||||
askFirst: true,
|
||||
verboseSlow: false,
|
||||
debug: process.env.DEBUG_22120 || false,
|
||||
checkPred: false
|
||||
|
|
Loading…
Reference in New Issue