mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: add inspect helper & warning (#1067)
This commit is contained in:
1 parent
5ebf48b694
commit
f32cee2200
2 files changed
+24
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { writeHeapSnapshot } from 'v8';
|
||||
import { pick } from 'lodash';
|
||||
import { lookup } from 'mime-types';
|
||||
import { Context } from '../context';
|
||||
@@ -139,10 +140,28 @@ export class SwitchAccountHandler extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
class HeapSnapshotHandler extends Handler {
|
||||
@param('worker', Types.Int)
|
||||
async post({ }, worker: number) {
|
||||
this.checkPriv(PRIV.PRIV_EDIT_SYSTEM);
|
||||
if (worker && process.env.NODE_APP_INSTANCE !== worker.toString()) {
|
||||
this.response.body = { error: 'Not current worker' };
|
||||
return;
|
||||
}
|
||||
this.response.body = {
|
||||
worker: process.env.NODE_APP_INSTANCE,
|
||||
filename: writeHeapSnapshot(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function apply(ctx: Context) {
|
||||
ctx.Route('switch_language', '/language/:lang', SwitchLanguageHandler);
|
||||
ctx.Route('home_files', '/file', FilesHandler);
|
||||
ctx.Route('fs_download', '/file/:uid/:filename', FSDownloadHandler);
|
||||
ctx.Route('storage', '/storage', StorageHandler);
|
||||
ctx.Route('switch_account', '/account/:uid', SwitchAccountHandler, PRIV.PRIV_EDIT_SYSTEM);
|
||||
if (process.argv.includes('--enable-heap-snapshot')) {
|
||||
ctx.Route('heap_snapshot', '/heap-snapshot', HeapSnapshotHandler, PRIV.PRIV_EDIT_SYSTEM);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user