1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

fix: refactor code

This commit is contained in:
Ivar Conradi Østhus 2021-06-18 11:53:52 +02:00
parent 4f9deee2ed
commit 2da26e7f14
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09

View File

@ -1,5 +1,3 @@
'use strict';
import EventEmitter from 'events'; import EventEmitter from 'events';
import stoppable, { StoppableServer } from 'stoppable'; import stoppable, { StoppableServer } from 'stoppable';
import { promisify } from 'util'; import { promisify } from 'util';
@ -19,14 +17,6 @@ import AuthenticationRequired from './types/authentication-required';
import * as eventType from './types/events'; import * as eventType from './types/events';
import { addEventHook } from './event-hook'; import { addEventHook } from './event-hook';
import registerGracefulShutdown from './util/graceful-shutdown'; import registerGracefulShutdown from './util/graceful-shutdown';
import { IUnleashStores } from './types/stores';
async function destroyDatabase(stores: IUnleashStores): Promise<void> {
const { db, clientInstanceStore, clientMetricsStore } = stores;
clientInstanceStore.destroy();
clientMetricsStore.destroy();
await db.destroy();
}
async function createApp( async function createApp(
config: IUnleashConfig, config: IUnleashConfig,
@ -47,7 +37,9 @@ async function createApp(
await stopServer(); await stopServer();
} }
metricsMonitor.stopMonitoring(); metricsMonitor.stopMonitoring();
await destroyDatabase(stores); stores.clientInstanceStore.destroy();
stores.clientMetricsStore.destroy();
await stores.db.destroy();
}; };
if (!config.server.secret) { if (!config.server.secret) {