MCPcopy Create free account
hub / github.com/evolution-foundation/evolution-api / onModuleInit

Method onModuleInit

src/api/provider/sessions.ts:26–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24 }
25
26 public async onModuleInit() {
27 if (this.config.ENABLED) {
28 const url = `http://${this.config.HOST}:${this.config.PORT}`;
29 try {
30 const response = await axios.options(url + '/ping');
31 if (response?.data != 'pong') {
32 throw new Error('Offline file provider.');
33 }
34
35 await axios.post(`${url}/session`, { group: this.config.PREFIX }, { headers: { apikey: this.globalApiToken } });
36 } catch (error) {
37 this.logger.error(['Failed to connect to the file server', error?.message, error?.stack]);
38 const pid = process.pid;
39 execFileSync('kill', ['-9', `${pid}`]);
40 }
41 }
42 }
43
44 public async onModuleDestroy() {
45 //

Callers 1

bootstrapFunction · 0.45

Calls 2

postMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected