Skip to content

Commit b5d0352

Browse files
feedback
1 parent d43f35b commit b5d0352

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

packages/backend/src/configManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ export class ConfigManager {
9393
});
9494

9595
if (connectionNeedsSyncing) {
96-
const [jobId] = await this.connectionManager.createJobs([connection]);
97-
logger.info(`Change detected for connection '${key}' (id: ${connection.id}). Created sync job ${jobId}.`);
96+
logger.info(`Change detected for connection '${key}' (id: ${connection.id}). Creating sync job.`);
97+
await this.connectionManager.createJobs([connection]);
9898
}
9999
}
100100
}

packages/backend/src/index.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ const prisma = new PrismaClient({
4242
const redis = new Redis(env.REDIS_URL, {
4343
maxRetriesPerRequest: null
4444
});
45-
redis.ping().then(() => {
45+
46+
try {
47+
await redis.ping();
4648
logger.info('Connected to redis');
47-
}).catch((err: unknown) => {
48-
logger.error('Failed to connect to redis');
49-
logger.error(err);
49+
} catch (err: unknown) {
50+
logger.error('Failed to connect to redis. Error:', err);
5051
process.exit(1);
51-
});
52+
}
5253

5354
const promClient = new PromClient();
5455

@@ -85,8 +86,6 @@ const api = new Api(
8586

8687
logger.info('Worker started.');
8788

88-
89-
9089
const listenToShutdownSignals = () => {
9190
const signals = SHUTDOWN_SIGNALS;
9291

@@ -115,29 +114,34 @@ const listenToShutdownSignals = () => {
115114

116115

117116
logger.info('All workers shut down gracefully');
118-
119117
signals.forEach(sig => process.removeListener(sig, cleanup));
120-
process.kill(process.pid, signal);
121118
} catch (error) {
122119
Sentry.captureException(error);
123120
logger.error('Error shutting down worker:', error);
124-
process.exit(1);
125121
}
126122
}
127123

128124
signals.forEach(signal => {
129-
process.on(signal, cleanup);
125+
process.on(signal, (err) => {
126+
cleanup(err).finally(() => {
127+
process.kill(process.pid, signal);
128+
});
129+
});
130130
});
131131

132132
// Register handlers for uncaught exceptions and unhandled rejections
133133
process.on('uncaughtException', (err) => {
134134
logger.error(`Uncaught exception: ${err.message}`);
135-
cleanup('uncaughtException').finally(() => process.exit(1));
135+
cleanup('uncaughtException').finally(() => {
136+
process.exit(1);
137+
});
136138
});
137139

138140
process.on('unhandledRejection', (reason, promise) => {
139141
logger.error(`Unhandled rejection at: ${promise}, reason: ${reason}`);
140-
cleanup('unhandledRejection').finally(() => process.exit(1));
142+
cleanup('unhandledRejection').finally(() => {
143+
process.exit(1);
144+
});
141145
});
142146

143147

0 commit comments

Comments
 (0)