mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-20 02:06:43 -06:00
feat: update server and monitor services
Updated server.module.ts and monitor.service.ts to improve service initialization and monitoring logic. Modified main.ts to integrate changes. This enhances the application's performance and reliability.
This commit is contained in:
parent
53cc6132f5
commit
5239e431c2
@ -1,5 +1,5 @@
|
|||||||
import { CacheEngine } from '../cache/cacheengine';
|
import { CacheEngine } from '../cache/cacheengine';
|
||||||
import { configService } from '../config/env.config';
|
import { configService, ProviderSession } from '../config/env.config';
|
||||||
import { eventEmitter } from '../config/event.config';
|
import { eventEmitter } from '../config/event.config';
|
||||||
import { Logger } from '../config/logger.config';
|
import { Logger } from '../config/logger.config';
|
||||||
import { dbserver } from '../libs/db.connect';
|
import { dbserver } from '../libs/db.connect';
|
||||||
@ -110,7 +110,12 @@ export const repository = new RepositoryBroker(
|
|||||||
export const cache = new CacheService(new CacheEngine(configService, 'instance').getEngine());
|
export const cache = new CacheService(new CacheEngine(configService, 'instance').getEngine());
|
||||||
const chatwootCache = new CacheService(new CacheEngine(configService, ChatwootService.name).getEngine());
|
const chatwootCache = new CacheService(new CacheEngine(configService, ChatwootService.name).getEngine());
|
||||||
const baileysCache = new CacheService(new CacheEngine(configService, 'baileys').getEngine());
|
const baileysCache = new CacheService(new CacheEngine(configService, 'baileys').getEngine());
|
||||||
const providerFiles = new ProviderFiles(configService);
|
|
||||||
|
let providerFiles: ProviderFiles = null;
|
||||||
|
|
||||||
|
if (configService.get<ProviderSession>('PROVIDER')?.ENABLED) {
|
||||||
|
providerFiles = new ProviderFiles(configService);
|
||||||
|
}
|
||||||
|
|
||||||
export const waMonitor = new WAMonitoringService(
|
export const waMonitor = new WAMonitoringService(
|
||||||
eventEmitter,
|
eventEmitter,
|
||||||
|
@ -323,7 +323,7 @@ export class WAMonitoringService {
|
|||||||
this.logger.verbose('Loading instances');
|
this.logger.verbose('Loading instances');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.providerSession.ENABLED) {
|
if (this.providerSession?.ENABLED) {
|
||||||
await this.loadInstancesFromProvider();
|
await this.loadInstancesFromProvider();
|
||||||
} else if (this.redis.REDIS.ENABLED && this.redis.REDIS.SAVE_INSTANCES) {
|
} else if (this.redis.REDIS.ENABLED && this.redis.REDIS.SAVE_INSTANCES) {
|
||||||
await this.loadInstancesFromRedis();
|
await this.loadInstancesFromRedis();
|
||||||
|
@ -12,7 +12,7 @@ import { initIO } from './api/integrations/websocket/libs/socket.server';
|
|||||||
import { ProviderFiles } from './api/provider/sessions';
|
import { ProviderFiles } from './api/provider/sessions';
|
||||||
import { HttpStatus, router } from './api/routes/index.router';
|
import { HttpStatus, router } from './api/routes/index.router';
|
||||||
import { waMonitor } from './api/server.module';
|
import { waMonitor } from './api/server.module';
|
||||||
import { Auth, configService, Cors, HttpServer, Rabbitmq, Sqs, Webhook } from './config/env.config';
|
import { Auth, configService, Cors, HttpServer, ProviderSession, Rabbitmq, Sqs, Webhook } from './config/env.config';
|
||||||
import { onUnexpectedError } from './config/error.config';
|
import { onUnexpectedError } from './config/error.config';
|
||||||
import { Logger } from './config/logger.config';
|
import { Logger } from './config/logger.config';
|
||||||
import { ROOT_DIR } from './config/path.config';
|
import { ROOT_DIR } from './config/path.config';
|
||||||
@ -27,9 +27,13 @@ async function bootstrap() {
|
|||||||
const logger = new Logger('SERVER');
|
const logger = new Logger('SERVER');
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
const providerFiles = new ProviderFiles(configService);
|
let providerFiles: ProviderFiles = null;
|
||||||
|
|
||||||
|
if (configService.get<ProviderSession>('PROVIDER')?.ENABLED) {
|
||||||
|
providerFiles = new ProviderFiles(configService);
|
||||||
await providerFiles.onModuleInit();
|
await providerFiles.onModuleInit();
|
||||||
logger.info('Provider:Files - ON');
|
logger.info('Provider:Files - ON');
|
||||||
|
}
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
cors({
|
cors({
|
||||||
|
Loading…
Reference in New Issue
Block a user