1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

fix: store snapshots in temp folder (#2864)

This commit is contained in:
Ivar Conradi Østhus 2023-01-10 13:53:00 +01:00 committed by GitHub
parent 8e5aeff1a7
commit 0c1e997f0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,6 @@
import { writeHeapSnapshot } from 'v8';
import { tmpdir } from 'os';
import { join } from 'path';
import { register as prometheusRegister } from 'prom-client';
import Controller from './controller';
import { IUnleashConfig } from '../types/option';
@ -20,7 +22,11 @@ class BackstageController extends Controller {
if (config.server.enableHeapSnapshotEnpoint) {
this.get('/heap-snapshot', async (req, res) => {
writeHeapSnapshot();
const fileName = join(
tmpdir(),
`unleash-${Date.now()}.heapsnapshot`,
);
writeHeapSnapshot(fileName);
res.status(200);
res.end('Snapshot written');
});