mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +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 fs = require('fs-extra');
|
||||
const { argv } = require('yargs');
|
||||
const hydro = require('../dist/loader');
|
||||
|
||||
if (!cluster.isMaster) {
|
||||
const hydro = require('../dist/loader');
|
||||
// Forked by hydro
|
||||
hydro.load().catch((e) => {
|
||||
console.error(e);
|
||||
@@ -46,6 +46,7 @@ if (!cluster.isMaster) {
|
||||
fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2));
|
||||
}
|
||||
} else {
|
||||
const hydro = require('../dist/loader');
|
||||
addons = Array.from(new Set(addons));
|
||||
for (const addon of addons) hydro.addon(addon);
|
||||
(argv._[0] === 'cli' ? hydro.loadCli : hydro.load)().catch((e) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.17.16",
|
||||
"version": "2.17.17",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
@@ -8,7 +8,7 @@
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0-only",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
"node": ">=13"
|
||||
},
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.5.2",
|
||||
@@ -34,6 +34,7 @@
|
||||
"superagent": "^6.1.0",
|
||||
"systeminformation": "^5.3.3",
|
||||
"terminal-kit": "^1.47.0",
|
||||
"wtfnode": "^0.8.4",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -52,6 +53,7 @@
|
||||
"@types/sockjs": "^0.3.32",
|
||||
"@types/superagent": "^4.1.8",
|
||||
"@types/terminal-kit": "^1.28.2",
|
||||
"@types/wtfnode": "^0.7.0",
|
||||
"@types/yargs": "^16.0.0",
|
||||
"formidable": "^1.2.2"
|
||||
},
|
||||
@@ -59,4 +61,4 @@
|
||||
"build": "tsc",
|
||||
"build:watch": "tsc --watch"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import path from 'path';
|
||||
import cluster from 'cluster';
|
||||
import fs from 'fs-extra';
|
||||
import { argv } from 'yargs';
|
||||
import wtfnode from 'wtfnode';
|
||||
import './utils';
|
||||
|
||||
export * from './interface';
|
||||
@@ -47,6 +48,14 @@ import * as bus from './service/bus';
|
||||
|
||||
const logger = new Logger('loader');
|
||||
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[] = []) {
|
||||
const _args = process.argv.slice(2);
|
||||
|
||||
@@ -6,8 +6,11 @@ import {
|
||||
} from 'terminal-kit';
|
||||
import { ProgressBarOptions } from 'terminal-kit/Terminal';
|
||||
import { argv } from 'yargs';
|
||||
import { Logger } from './logger';
|
||||
import * as bus from './service/bus';
|
||||
|
||||
const logger = new Logger('ui');
|
||||
|
||||
declare module 'terminal-kit/Terminal' {
|
||||
interface ProgressBarOptions {
|
||||
y?: number;
|
||||
@@ -46,12 +49,11 @@ export namespace Progress {
|
||||
async function terminate() {
|
||||
let hasError = false;
|
||||
try {
|
||||
await require('./service/bus').parallel('app/exit');
|
||||
await bus.parallel('app/exit');
|
||||
} catch (e) {
|
||||
hasError = true;
|
||||
}
|
||||
if (useTerminal) {
|
||||
terminal.hideCursor(false);
|
||||
terminal.styleReset();
|
||||
terminal.resetScrollingRegion();
|
||||
terminal.moveTo(terminal.width, terminal.height);
|
||||
@@ -64,7 +66,6 @@ process.on('SIGINT', terminate);
|
||||
if (useTerminal) {
|
||||
terminal.clear();
|
||||
terminal.grabInput();
|
||||
terminal.hideCursor();
|
||||
// Clipboard doesn't work well over ssh env, it throws an error.
|
||||
terminal.getClipboard = () => { };
|
||||
terminal.setClipboard = () => { };
|
||||
@@ -92,7 +93,7 @@ if (useTerminal) {
|
||||
});
|
||||
const history = [''];
|
||||
let current = 0;
|
||||
ShellInput.on('submit', async (input) => {
|
||||
ShellInput.on('submit', async (input: string) => {
|
||||
history.push(input);
|
||||
current = history.length;
|
||||
ShellInput.input.setContent(' '.repeat(terminal.width), false, false);
|
||||
@@ -118,6 +119,9 @@ if (useTerminal) {
|
||||
terminal.on('key', (key) => {
|
||||
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) {
|
||||
console.log('Not running in a terminal environment. Interactive mode disabled.');
|
||||
bus.on('message/log', (message) => {
|
||||
|
||||
Reference in new issue
Block a user