📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
clickhouse: close connections on application shutdown
Blue Mouse88c3165f2ea4
diff --git a/apps/production/src/app.controller.ts b/apps/production/src/app.controller.tsindex dfedefb2c..c8ef60282 100644--- a/apps/production/src/app.controller.ts+++ b/apps/production/src/app.controller.ts@@ -1,4 +1,5 @@-import { Get, Controller } from '@nestjs/common'+import { Get, Controller, OnApplicationShutdown } from '@nestjs/common'+import { clickhouse } from './common/integrations/clickhouse'const DEPLOYMENT_INFORMATION = {name: 'Swetrix API',@@ -8,7 +9,11 @@ const DEPLOYMENT_INFORMATION = {}@Controller()-export class AppController {+export class AppController implements OnApplicationShutdown {+ async onApplicationShutdown(): Promise<void> {+ await clickhouse.close()+ }+@Get()root(): any {return DEPLOYMENT_INFORMATIONdiff --git a/apps/production/src/main.ts b/apps/production/src/main.tsindex f7ce264f4..525c62a29 100644--- a/apps/production/src/main.ts+++ b/apps/production/src/main.ts@@ -67,6 +67,8 @@ async function bootstrap() {app.use(bot.webhookCallback(process.env.TELEGRAM_WEBHOOK_PATH))}+ app.enableShutdownHooks()+await app.listen(5005)}bootstrap()diff --git a/apps/selfhosted/src/app.controller.ts b/apps/selfhosted/src/app.controller.tsindex dfedefb2c..c8ef60282 100644--- a/apps/selfhosted/src/app.controller.ts+++ b/apps/selfhosted/src/app.controller.ts@@ -1,4 +1,5 @@-import { Get, Controller } from '@nestjs/common'+import { Get, Controller, OnApplicationShutdown } from '@nestjs/common'+import { clickhouse } from './common/integrations/clickhouse'const DEPLOYMENT_INFORMATION = {name: 'Swetrix API',@@ -8,7 +9,11 @@ const DEPLOYMENT_INFORMATION = {}@Controller()-export class AppController {+export class AppController implements OnApplicationShutdown {+ async onApplicationShutdown(): Promise<void> {+ await clickhouse.close()+ }+@Get()root(): any {return DEPLOYMENT_INFORMATIONdiff --git a/apps/selfhosted/src/main.ts b/apps/selfhosted/src/main.tsindex caf9e15e4..937a50324 100644--- a/apps/selfhosted/src/main.ts+++ b/apps/selfhosted/src/main.ts@@ -51,6 +51,8 @@ async function bootstrap() {next()})+ app.enableShutdownHooks()+await app.listen(5005)}bootstrap()