Bugfix/fix database connection error handling (#1125)
* Fix database connection error handling * Update changelog
This commit is contained in:
parent
03942aecda
commit
69bc1d67e1
@ -14,11 +14,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- Refactored the initialization of the exchange rate service
|
||||||
- Upgraded `angular` from version `14.0.2` to `14.1.0`
|
- Upgraded `angular` from version `14.0.2` to `14.1.0`
|
||||||
- Upgraded `nestjs` from version `8.4.7` to `9.0.7`
|
- Upgraded `nestjs` from version `8.4.7` to `9.0.7`
|
||||||
- Upgraded `Nx` from version `14.3.5` to `14.5.1`
|
- Upgraded `Nx` from version `14.3.5` to `14.5.1`
|
||||||
- Upgraded `prisma` from version `3.15.2` to `4.1.1`
|
- Upgraded `prisma` from version `3.15.2` to `4.1.1`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Handled database connection errors (do not exit process)
|
||||||
|
|
||||||
## 1.176.2 - 31.07.2022
|
## 1.176.2 - 31.07.2022
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -1,6 +1,20 @@
|
|||||||
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { Controller } from '@nestjs/common';
|
import { Controller } from '@nestjs/common';
|
||||||
|
|
||||||
@Controller()
|
@Controller()
|
||||||
export class AppController {
|
export class AppController {
|
||||||
public constructor() {}
|
public constructor(
|
||||||
|
private readonly exchangeRateDataService: ExchangeRateDataService,
|
||||||
|
private readonly prismaService: PrismaService
|
||||||
|
) {
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async initialize() {
|
||||||
|
try {
|
||||||
|
await this.prismaService.$connect();
|
||||||
|
await this.exchangeRateDataService.initialize();
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
} from '@prisma/client';
|
} from '@prisma/client';
|
||||||
import Big from 'big.js';
|
import Big from 'big.js';
|
||||||
import { endOfToday, isAfter } from 'date-fns';
|
import { endOfToday, isAfter } from 'date-fns';
|
||||||
import { groupBy, isString } from 'lodash';
|
import { groupBy } from 'lodash';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import { Activity } from './interfaces/activities.interface';
|
import { Activity } from './interfaces/activities.interface';
|
||||||
|
@ -22,9 +22,7 @@ export class ExchangeRateDataService {
|
|||||||
private readonly dataProviderService: DataProviderService,
|
private readonly dataProviderService: DataProviderService,
|
||||||
private readonly prismaService: PrismaService,
|
private readonly prismaService: PrismaService,
|
||||||
private readonly propertyService: PropertyService
|
private readonly propertyService: PropertyService
|
||||||
) {
|
) {}
|
||||||
this.initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public getCurrencies() {
|
public getCurrencies() {
|
||||||
return this.currencies?.length > 0 ? this.currencies : [this.baseCurrency];
|
return this.currencies?.length > 0 ? this.currencies : [this.baseCurrency];
|
||||||
|
@ -1,15 +1,25 @@
|
|||||||
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
import {
|
||||||
|
Injectable,
|
||||||
|
Logger,
|
||||||
|
OnModuleDestroy,
|
||||||
|
OnModuleInit
|
||||||
|
} from '@nestjs/common';
|
||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PrismaService
|
export class PrismaService
|
||||||
extends PrismaClient
|
extends PrismaClient
|
||||||
implements OnModuleInit, OnModuleDestroy {
|
implements OnModuleInit, OnModuleDestroy
|
||||||
async onModuleInit() {
|
{
|
||||||
await this.$connect();
|
public async onModuleInit() {
|
||||||
|
try {
|
||||||
|
await this.$connect();
|
||||||
|
} catch (error) {
|
||||||
|
Logger.error(error, 'PrismaService');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModuleDestroy() {
|
public async onModuleDestroy() {
|
||||||
await this.$disconnect();
|
await this.$disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user