mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: import.syzoj: async
This commit is contained in:
1 parent
b7330b05d1
commit
e3dad8ff60
6 files changed
+29
-17
No files matched your search
@@ -5,8 +5,10 @@ import { safeDump } from 'js-yaml';
|
||||
import db from './db';
|
||||
import * as bus from './bus';
|
||||
import * as sysinfo from '../lib/sysinfo';
|
||||
import { Logger } from '../logger';
|
||||
|
||||
const coll = db.collection('status');
|
||||
const logger = new Logger('monitor');
|
||||
|
||||
function crypt(str: string) {
|
||||
const cipher = crypto.createCipheriv('des-ecb', 'hydro-oj', '');
|
||||
@@ -47,7 +49,9 @@ export async function feedback() {
|
||||
cpu: inf.cpu,
|
||||
flags: inf.flags,
|
||||
}));
|
||||
axios.post('https://feedback.undefined.moe/', { payload });
|
||||
axios.post('https://feedback.undefined.moe/', { payload }).catch(() => {
|
||||
logger.warn('Cannot connect to hydro center.');
|
||||
});
|
||||
}
|
||||
|
||||
export async function update() {
|
||||
|
||||
@@ -556,7 +556,10 @@ export class Handler {
|
||||
const templateName = this.request.query.template || this.response.template;
|
||||
if (templateName) {
|
||||
this.response.body = this.response.body || {};
|
||||
await this.render(templateName, this.response.body);
|
||||
const s = templateName.split('.');
|
||||
if (global.Hydro.ui.template[`${s[0]}.${this.domainId}.${s[1]}`]) {
|
||||
await this.render(`${s[0]}.${this.domainId}.${s[1]}`, this.response.body);
|
||||
} else await this.render(templateName, this.response.body);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -620,8 +623,9 @@ export class Handler {
|
||||
|
||||
async onerror(error: HydroError) {
|
||||
if (!error.msg) error.msg = () => error.message;
|
||||
if (error instanceof UserFacingError) error.stack = '';
|
||||
if (!(error instanceof NotFoundError)) {
|
||||
logger.error(error.msg(), error.params);
|
||||
logger.error(this.request.path, error.msg(), error.params);
|
||||
logger.error(error.stack);
|
||||
}
|
||||
this.response.status = error instanceof UserFacingError ? error.code : 500;
|
||||
@@ -813,6 +817,7 @@ export class ConnectionHandler {
|
||||
async message(message: any) { } // eslint-disable-line
|
||||
|
||||
onerror(err: HydroError) {
|
||||
if (err instanceof UserFacingError) err.stack = this.conn.pathname;
|
||||
if (!(err instanceof NotFoundError)) logger.error(err);
|
||||
this.send({
|
||||
error: {
|
||||
|
||||
Reference in new issue
Block a user