Skip to content

Commit

Permalink
fix: exit app if not connection on rabbitmq
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheus Paice committed Apr 17, 2024
1 parent b3ebf84 commit 467ccdf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vtru-studio-websocket",
"version": "1.1.32",
"version": "1.1.33",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/controllers/notify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const uniqueId = nanoid();
export const start = async () => {
const channel = await getChannel();

channel?.on('close', () => {
process.exit(1);
})

const notificationQueue = `${RABBITMQ_EXCHANGE_CREATORS}.notifications.${uniqueId}`;

channel?.assertExchange(RABBITMQ_EXCHANGE_CREATORS, 'topic', {
Expand Down
4 changes: 4 additions & 0 deletions src/controllers/preSignedURL/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const uniqueId = nanoid();
export const start = async () => {
const channel = await getChannel();

channel?.on('close', () => {
process.exit(1);
});

const logQueue = `${RABBITMQ_EXCHANGE_CREATORS}.assets.${uniqueId}`;

channel?.assertExchange(RABBITMQ_EXCHANGE_CREATORS, 'topic', {
Expand Down
2 changes: 2 additions & 0 deletions src/services/rabbitmq/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export const getChannel = async () => {
process.exit(1);
} catch (error) {
captureException(error, { tags: { scope: 'rabbitmq' } });

process.exit(1);
}
return null;
};
Expand Down

0 comments on commit 467ccdf

Please sign in to comment.