mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +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
@@ -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