Skip to content

Commit a7a1519

Browse files
committed
chore: Add Redis connection event logging in BackendRunnerService
1 parent f43c2df commit a7a1519

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/backend-runner/backend-runner.service.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
3838
this.executors.set('*', new CatchAllExecutor(this));
3939
this.executors.set(ActionType.LIST_BACKENDS, new ListBackendsExecutor(this));
4040

41+
this.redis.on('connecting', () => this.logger.verbose(`Redis connecting... 🟡`));
42+
this.redis.on('connect', () => this.logger.log(`Redis connected 🟢`));
43+
this.redis.on('ready', () => this.logger.debug(`Redis ready to listen jobs 🟣`));
44+
this.redis.on('close', () => this.logger.fatal(`Redis connection closed 🟥`));
45+
4146
this.logger.log('OnModuleInit initialized 🔴');
4247
}
4348

@@ -70,7 +75,16 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
7075
autorun: false,
7176
},
7277
);
73-
worker.run();
78+
79+
worker.on('active', () => this.logger.log(`Worker now active 🟢`));
80+
worker.on('resumed', () => this.logger.log(`Worker now resumed 🟢`));
81+
worker.on('error', (err) => this.logger.error(err));
82+
worker.on('closed', () => {
83+
this.logger.fatal(`Worker closed 🟥`);
84+
process.exit(1);
85+
});
86+
87+
await worker.run();
7488
this.logger.log('OnApplicationBootstrap initialized 🔴');
7589
}
7690
}

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default (): ConfigInstance => {
3030
options: {
3131
showFriendlyErrorStack: true,
3232
maxRetriesPerRequest: null,
33+
retryStrategy: (times) => Math.min(times * 1_000, 10_000),
3334
},
3435
},
3536
};

0 commit comments

Comments
 (0)