Skip to content

Commit e9bd99e

Browse files
committed
Update .env.example and backend-runner.service.ts to improve configuration and logging
- Added comments in .env.example for clarity on Redis configuration. - Removed commented-out code in backend-runner.service.ts to clean up the codebase. - Enhanced error logging for job execution failures. - Set concurrency to 5 for job processing in backend-runner.service.ts.
1 parent 601c3aa commit e9bd99e

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
SESAME_REDIS_URI=redis://localhost:6379/0
2+
# Même Redis que l'orchestrateur (host/port/db).
3+
# SESAME_NAME_QUEUE=sesame

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,16 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
4444
this._package = {};
4545
try {
4646
if (existsSync('/snapshot/data/package.json')) {
47-
// Build from local
4847
this._package = JSON.parse(readFileSync('/snapshot/data/package.json', 'utf-8'));
4948
} else if (existsSync('/snapshot/sesame-daemon/package.json')) {
50-
// Build from github
5149
this._package = JSON.parse(readFileSync('/snapshot/sesame-daemon/package.json', 'utf-8'));
5250
} else {
53-
// General case
5451
this._package = JSON.parse(readFileSync('package.json', 'utf-8'));
5552
}
5653
} catch (e) {
5754
this._logger.error('Error reading package.json file: ', e);
5855
this._package = {};
5956
}
60-
// console.log('pkg', (process as any).pkg)
61-
// console.log('pkg', this._package)
6257
}
6358

6459
public async onModuleInit() {
@@ -96,11 +91,10 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
9691
this.logger.verbose(`Job ${job.name} executed with status ${result.status}`);
9792

9893
if (result.status !== 0) {
99-
const errMsg = []
10094
this.logger.error(`Job ${job.name} failed with status ${result.status}`);
10195

10296
for (const data of result.data) {
103-
errMsg.push(data?.error?.message || 'No error message');
97+
this.logger.error(data?.error?.message || 'No error message');
10498
}
10599

106100
return result;
@@ -112,14 +106,15 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
112106
{
113107
connection: this.redis.duplicate(),
114108
autorun: false,
109+
concurrency: 5,
115110
removeOnComplete: {
116111
age: 60 * 60 * 24 * 7,
117112
count: 2_500,
118113
},
119114
removeOnFail: {
120115
age: 60 * 60 * 24 * 7,
121116
count: 2_500,
122-
}, //TODO: Add to config
117+
},
123118
},
124119
);
125120

0 commit comments

Comments
 (0)