mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: 修复hydrooj addon运行完成后不会自行退出的问题
This commit is contained in:
1 parent
3f78c35359
commit
f9aef434cb
4 files changed
+24
-8
No files matched your search
@@ -5,9 +5,9 @@ const path = require('path');
|
|||||||
const cluster = require('cluster');
|
const cluster = require('cluster');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const { argv } = require('yargs');
|
const { argv } = require('yargs');
|
||||||
const hydro = require('../dist/loader');
|
|
||||||
|
|
||||||
if (!cluster.isMaster) {
|
if (!cluster.isMaster) {
|
||||||
|
const hydro = require('../dist/loader');
|
||||||
// Forked by hydro
|
// Forked by hydro
|
||||||
hydro.load().catch((e) => {
|
hydro.load().catch((e) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@@ -46,6 +46,7 @@ if (!cluster.isMaster) {
|
|||||||
fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2));
|
fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
const hydro = require('../dist/loader');
|
||||||
addons = Array.from(new Set(addons));
|
addons = Array.from(new Set(addons));
|
||||||
for (const addon of addons) hydro.addon(addon);
|
for (const addon of addons) hydro.addon(addon);
|
||||||
(argv._[0] === 'cli' ? hydro.loadCli : hydro.load)().catch((e) => {
|
(argv._[0] === 'cli' ? hydro.loadCli : hydro.load)().catch((e) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.17.16",
|
"version": "2.17.17",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14"
|
"node": ">=13"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"adm-zip": "^0.5.2",
|
"adm-zip": "^0.5.2",
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
"superagent": "^6.1.0",
|
"superagent": "^6.1.0",
|
||||||
"systeminformation": "^5.3.3",
|
"systeminformation": "^5.3.3",
|
||||||
"terminal-kit": "^1.47.0",
|
"terminal-kit": "^1.47.0",
|
||||||
|
"wtfnode": "^0.8.4",
|
||||||
"yargs": "^16.2.0"
|
"yargs": "^16.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -52,6 +53,7 @@
|
|||||||
"@types/sockjs": "^0.3.32",
|
"@types/sockjs": "^0.3.32",
|
||||||
"@types/superagent": "^4.1.8",
|
"@types/superagent": "^4.1.8",
|
||||||
"@types/terminal-kit": "^1.28.2",
|
"@types/terminal-kit": "^1.28.2",
|
||||||
|
"@types/wtfnode": "^0.7.0",
|
||||||
"@types/yargs": "^16.0.0",
|
"@types/yargs": "^16.0.0",
|
||||||
"formidable": "^1.2.2"
|
"formidable": "^1.2.2"
|
||||||
},
|
},
|
||||||
@@ -59,4 +61,4 @@
|
|||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"build:watch": "tsc --watch"
|
"build:watch": "tsc --watch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import path from 'path';
|
|||||||
import cluster from 'cluster';
|
import cluster from 'cluster';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import { argv } from 'yargs';
|
import { argv } from 'yargs';
|
||||||
|
import wtfnode from 'wtfnode';
|
||||||
import './utils';
|
import './utils';
|
||||||
|
|
||||||
export * from './interface';
|
export * from './interface';
|
||||||
@@ -47,6 +48,14 @@ import * as bus from './service/bus';
|
|||||||
|
|
||||||
const logger = new Logger('loader');
|
const logger = new Logger('loader');
|
||||||
logger.debug('%o', argv);
|
logger.debug('%o', argv);
|
||||||
|
bus.on('app/exit', () => {
|
||||||
|
if (argv.debug) {
|
||||||
|
wtfnode.setLogger('info', logger.info.bind(logger));
|
||||||
|
wtfnode.setLogger('warn', logger.warn.bind(logger));
|
||||||
|
wtfnode.setLogger('error', logger.error.bind(logger));
|
||||||
|
wtfnode.dump();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
async function fork(args: string[] = []) {
|
async function fork(args: string[] = []) {
|
||||||
const _args = process.argv.slice(2);
|
const _args = process.argv.slice(2);
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ import {
|
|||||||
} from 'terminal-kit';
|
} from 'terminal-kit';
|
||||||
import { ProgressBarOptions } from 'terminal-kit/Terminal';
|
import { ProgressBarOptions } from 'terminal-kit/Terminal';
|
||||||
import { argv } from 'yargs';
|
import { argv } from 'yargs';
|
||||||
|
import { Logger } from './logger';
|
||||||
import * as bus from './service/bus';
|
import * as bus from './service/bus';
|
||||||
|
|
||||||
|
const logger = new Logger('ui');
|
||||||
|
|
||||||
declare module 'terminal-kit/Terminal' {
|
declare module 'terminal-kit/Terminal' {
|
||||||
interface ProgressBarOptions {
|
interface ProgressBarOptions {
|
||||||
y?: number;
|
y?: number;
|
||||||
@@ -46,12 +49,11 @@ export namespace Progress {
|
|||||||
async function terminate() {
|
async function terminate() {
|
||||||
let hasError = false;
|
let hasError = false;
|
||||||
try {
|
try {
|
||||||
await require('./service/bus').parallel('app/exit');
|
await bus.parallel('app/exit');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
}
|
}
|
||||||
if (useTerminal) {
|
if (useTerminal) {
|
||||||
terminal.hideCursor(false);
|
|
||||||
terminal.styleReset();
|
terminal.styleReset();
|
||||||
terminal.resetScrollingRegion();
|
terminal.resetScrollingRegion();
|
||||||
terminal.moveTo(terminal.width, terminal.height);
|
terminal.moveTo(terminal.width, terminal.height);
|
||||||
@@ -64,7 +66,6 @@ process.on('SIGINT', terminate);
|
|||||||
if (useTerminal) {
|
if (useTerminal) {
|
||||||
terminal.clear();
|
terminal.clear();
|
||||||
terminal.grabInput();
|
terminal.grabInput();
|
||||||
terminal.hideCursor();
|
|
||||||
// Clipboard doesn't work well over ssh env, it throws an error.
|
// Clipboard doesn't work well over ssh env, it throws an error.
|
||||||
terminal.getClipboard = () => { };
|
terminal.getClipboard = () => { };
|
||||||
terminal.setClipboard = () => { };
|
terminal.setClipboard = () => { };
|
||||||
@@ -92,7 +93,7 @@ if (useTerminal) {
|
|||||||
});
|
});
|
||||||
const history = [''];
|
const history = [''];
|
||||||
let current = 0;
|
let current = 0;
|
||||||
ShellInput.on('submit', async (input) => {
|
ShellInput.on('submit', async (input: string) => {
|
||||||
history.push(input);
|
history.push(input);
|
||||||
current = history.length;
|
current = history.length;
|
||||||
ShellInput.input.setContent(' '.repeat(terminal.width), false, false);
|
ShellInput.input.setContent(' '.repeat(terminal.width), false, false);
|
||||||
@@ -118,6 +119,9 @@ if (useTerminal) {
|
|||||||
terminal.on('key', (key) => {
|
terminal.on('key', (key) => {
|
||||||
if (key === 'CTRL_C') terminate();
|
if (key === 'CTRL_C') terminate();
|
||||||
});
|
});
|
||||||
|
if (process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.SSH_CONNECTION) {
|
||||||
|
logger.warn('Running over ssh detected. Add a --legacy when starting if GUI mode doesn\'t work properly.');
|
||||||
|
}
|
||||||
} else if (cluster.isMaster) {
|
} else if (cluster.isMaster) {
|
||||||
console.log('Not running in a terminal environment. Interactive mode disabled.');
|
console.log('Not running in a terminal environment. Interactive mode disabled.');
|
||||||
bus.on('message/log', (message) => {
|
bus.on('message/log', (message) => {
|
||||||
|
|||||||
Reference in new issue
Block a user