Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Move RabbitMQ kill script to 'meta' folder

Blue Mousec8c519b05119
diff --git a/kill_all_jobs_rmq.ts b/kill_all_jobs_rmq.ts
deleted file mode 100644
index c633efc53..000000000
--- a/kill_all_jobs_rmq.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { Queue } from 'bullmq';
-
-async function cleanAllJobs(queueName: string) {
- const queue = new Queue(queueName, {
- connection: {
- host: 'localhost',
- port: 6379,
- // Add other Redis connection options if needed
- },
- });
-
- try {
- // Clean all completed jobs
- await queue.clean(0, 1000, 'completed');
- console.log('Completed jobs cleaned');
-
- // Clean all waiting jobs
- await queue.clean(0, 1000, 'wait');
- console.log('Waiting jobs cleaned');
-
- // Clean all active jobs
- await queue.clean(0, 1000, 'active');
- console.log('Active jobs cleaned');
-
- // Clean all delayed jobs
- await queue.clean(0, 1000, 'delayed');
- console.log('Delayed jobs cleaned');
-
- // Clean all failed jobs
- await queue.clean(0, 1000, 'failed');
- console.log('Failed jobs cleaned');
-
- // Drain the queue (remove all jobs)
- await queue.drain();
- console.log('Queue drained');
-
- // Obliterate the queue (remove all data and jobs associated with the queue)
- await queue.obliterate({ force: true });
- console.log('Queue obliterated');
-
- } catch (error) {
- console.error('Error cleaning jobs:', error);
- } finally {
- await queue.close();
- }
-}
-
-cleanAllJobs('monitor');
diff --git a/meta/kill_all_jobs_rmq.js b/meta/kill_all_jobs_rmq.js
new file mode 100644
index 000000000..c80c10caa
--- /dev/null
+++ b/meta/kill_all_jobs_rmq.js
@@ -0,0 +1,49 @@
+/* eslint-disable @typescript-eslint/no-require-imports */
+const { Queue } = require('bullmq')
+require('dotenv').config()
+
+async function cleanAllJobs(queueName) {
+ const queue = new Queue(queueName, {
+ connection: {
+ host: process.env.REDIS_HOST,
+ port: process.env.REDIS_PORT,
+ // Add other Redis connection options if needed
+ },
+ })
+
+ try {
+ // Clean all completed jobs
+ await queue.clean(0, 1000, 'completed')
+ console.log('Completed jobs cleaned')
+
+ // Clean all waiting jobs
+ await queue.clean(0, 1000, 'wait')
+ console.log('Waiting jobs cleaned')
+
+ // Clean all active jobs
+ await queue.clean(0, 1000, 'active')
+ console.log('Active jobs cleaned')
+
+ // Clean all delayed jobs
+ await queue.clean(0, 1000, 'delayed')
+ console.log('Delayed jobs cleaned')
+
+ // Clean all failed jobs
+ await queue.clean(0, 1000, 'failed')
+ console.log('Failed jobs cleaned')
+
+ // Drain the queue (remove all jobs)
+ await queue.drain()
+ console.log('Queue drained')
+
+ // Obliterate the queue (remove all data and jobs associated with the queue)
+ await queue.obliterate({ force: true })
+ console.log('Queue obliterated')
+ } catch (error) {
+ console.error('Error cleaning jobs:', error)
+ } finally {
+ await queue.close()
+ }
+}
+
+cleanAllJobs('monitor')