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 15, 2024
1 parent c656f8e commit b3ebf84
Show file tree
Hide file tree
Showing 3 changed files with 8 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.31",
"version": "1.1.32",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions src/services/rabbitmq/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const getConnection = async () => {
status.isConnected = false;
status.connection = null;
console.error('RabbitMQ connection closed');
process.exit(1);
});
status.connection.on('error', (error) => {
status.isConnected = false;
Expand All @@ -42,6 +43,7 @@ export const getConnection = async () => {
status.connection = null;
captureException(err, { tags: { scope: 'rabbitmq' } });
logger('Error connecting to rabbitmq: %O', err);
process.exit(1);
}
return status;
};
Expand All @@ -53,6 +55,9 @@ export const getChannel = async () => {
if (connection) {
return connection.createChannel();
}

// if connection is null
process.exit(1);
} catch (error) {
captureException(error, { tags: { scope: 'rabbitmq' } });
}
Expand Down

0 comments on commit b3ebf84

Please sign in to comment.